Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > Flash (all versions)
| Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Flash (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 27th, 2007, 04:17 PM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to modify flash so it pulls php url every 15 s

Hi flash experts. could any one tell me how to modify flash .fla file so it pulls a .php url every 15 seconds without need to refrsh to the whole page that contains the flash. Here is how the flash is placed in page. I never worked in flash so i be happy if an expert have a look at it. I also can post the source code.Thanks:

Code:
<object type="application/x-shockwave-flash" data="./imagerotator.swf" height="180" width="448">
  <param name="movie" value="./imagerotator.swf" />
  <param name="allownetworking" value="internal" />
  <param name="allowScriptAccess" value="never" />
  <param name="enableJSURL" value="false" />
  <param name="enableHREF" value="false" />
  <param name="saveEmbedTags" value="true" />
  <param name="bgcolor" value="#FFFFFF" />
  <param name="flashvars" value="file=externalfeed.php&autostart=true&transition=fade&shownavigation=false&rotatetime:4&shuffle=true" />
  <param name="wmode" value="transparent" />
</object>
</div>
pic of .fla
http://img3.freeimagehosting.net/ima...665f71e4ea.jpg

.fla to download:
http://www.wikiupload.com/download_page.php?id=91160

  #2 (permalink)  
Old February 27th, 2007, 04:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could call the php file from within flash using set interval and loadvars. In the example remove the max count and replace the .txt file with your php file.

var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 10;
var duration:Number = 15000;

function executeCallback():Void {
    trace("executeCallback intervalId: " + intervalId + " count: " + count);

    var my_lv:LoadVars = new LoadVars();
    my_lv.onLoad = function(success:Boolean) {
        if (success) {
            trace("Success");
        } else {
            trace("Error loading/parsing LoadVars.");
        }
    };
    my_lv.load("http://www.helpexamples.com/flash/params.txt")

    if(count >= maxCount) {
        clearInterval(intervalId);
    }
    count++;
}

intervalId = setInterval(this, "executeCallback", duration);
  #3 (permalink)  
Old February 27th, 2007, 05:13 PM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

harpua.Thanks for your reply. The .fla was not made by me.I have flash 8 installd. could you tell me what part i need to modify? I am not femiler with flash intrface.Where to paste your code? You can look at .fla file i have uploaded.


 Furthermor, you mean inside .txt i place call to my flash file or content of flash file which reads remote xml files? or replace the url to call to my .php file ?
  #4 (permalink)  
Old February 27th, 2007, 05:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if you are looking to load content into flash every 15 seconds you could use this script, I cleaned it up. If you are wanting to reload the .swf file on the webpage every 15seconds I am not sure what to do there.

Not trying to sound mean here, but If you are wanting to load external content into flash, and you unfamiliar with flash you might want to get a book on actionscript or do some research on flash and loadVars. Also if you are wanting to load XML, look into load (XML.load method). The flash help is a great resource and can go into better detail with examples.

var duration:Number = 15000;

function executeCallback():Void {
    var my_lv:LoadVars = new LoadVars();
    my_lv.onLoad = function(success:Boolean) {
        if (success) {
            trace("Success have actionscript process php content.");
        } else {
            trace("Error loading/parsing LoadVars.");
        }
    };
    my_lv.load("http://www.someplace.com/my_php_file.php")

}

intervalId = setInterval(this, "executeCallback", duration);
  #5 (permalink)  
Old February 27th, 2007, 06:19 PM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The .swf/.fla file already executes the php and diplays image from remote xml but the only thing it has old data if you do not refresh it. I guess i can't explain what i want. I wanted fresh data every few seconds by calling php automatically from within flash.

I tested your code by doing the follwoing:

-open a new flash document

-select the first keyfram of the defaul layr of the main timeline

-open action panel and past your code

-test your code by ctrl + Enter

when testing i did not see any thing in output panel !!

Actually i asked for help on how to modify current .fla and
still do not know where to use your code!! The current .fla reads data from remote xml with help of php but only does not update itself evry few seconds!!

Note: i have action script bible and it is myfirst day to work in flash

Here is part of the code i could view using .swf decompiler.Unfortunetenly i could not find it using flsh 8!!



Code:
// Action script...

// [Initial MovieClip Action of sprite 85]
#initclip 1
class com.jeroenwijering.players.AbstractPlayer
{
    var controller, fileArray, fileTypes, fileParser, parseArray;
    function AbstractPlayer(tgt, fil)
    {
        configArray.playerclip = tgt;
        configArray.playerclip._visible = false;
        fil == undefined ? (null) : (configArray.file = fil);
        this.loadConfig();
    } // End of the function
    function loadConfig()
    {
        configArray.width == "undefined" ? (configArray.width = Stage.width) : (null);
        configArray.height == "undefined" ? (configArray.height = Stage.height) : (null);
        for (var _loc3 in configArray)
        {
            _root[_loc3] == undefined ? (null) : (configArray[_loc3] = unescape(_root[_loc3]));
        } // end of for...in
        configArray.displayheight == "undefined" ? (configArray.displayheight = configArray.height - 20) : (null);
        if (configArray.fullscreenmode == "true")
        {
            var _loc4 = SharedObject.getLocal("com.jeroenwijering.players", "/");
            configArray.file = _loc4.data.file;
            configArray.captions = _loc4.data.captions;
            configArray.fsreturnpage = _loc4.data.fsreturnpage;
        } // end if
        configArray.enablejs == "true" ? (this.enableLoadFile()) : (null);
        this.loadFile(configArray.file);
    } // End of the function
    function loadFile(fil, tit, lnk, img, fid)    {
        if (controller != undefined)
        {
            controller.getEvent("stop");
            delete this.controller;
        } // end if
        configArray.file = fil;
        tit == undefined ? (null) : (_root.title = tit);
        lnk == undefined ? (null) : (_root.link = lnk);
        img == undefined ? (null) : (_root.image = img);
        fid == undefined ? (null) : (_root.id = fid);
        fileArray = new Array();
        var _loc4 = false;
        for (var _loc6 in fileTypes)
        {
            if (fil.toLowerCase().indexOf(fileTypes[_loc6].toLowerCase()) > -1)
            {
                _loc4 = true;
            } // end if
        } // end of for...in
        if (_loc4 == true)
        {
            fileArray[0] = new Object();
            fileArray[0].file = fil;
            for (var _loc5 in fileElements)
            {
                _root[_loc5] == undefined ? (null) : (fileArray[0][_loc5] = unescape(_root[_loc5]));
            } // end of for...in
            if (configArray.fullscreenmode == "true")
            {
                var _loc7 = SharedObject.getLocal("com.jeroenwijering.players", "/");
                fileArray[0].id = _loc7.data.id;
            } // end if
            configArray.playerclip._visible = true;
            _root.activity._visible = false;
            this.setupMCV();
        }
        else
        {
            var ref = this;
            fileParser = new com.jeroenwijering.utils.FeedParser();
            fileParser.onParseComplete = function ()
            {
                ref.fileArray = parseArray;
                ref.configArray.playerclip._visible = true;
                _root.activity._visible = false;
                ref.setupMCV();
            };
            fileParser.parse(fil);
        } // end else if
    } // End of the function
    function setupMCV()
    {
        controller = new com.jeroenwijering.players.AbstractController(configArray, fileArray);
        var _loc5 = new com.jeroenwijering.players.AbstractView(controller, configArray, fileArray);
        var _loc2 = new Array(_loc5);
        var _loc3 = new com.jeroenwijering.players.AbstractModel(_loc2, controller, configArray, fileArray);
        var _loc4 = new Array(_loc3);
        controller.startMCV(_loc4);
    } // End of the function
    function enableLoadFile()
    {
        if (flash.external.ExternalInterface.available)
        {
            var _loc2 = flash.external.ExternalInterface.addCallback("loadFile", this, loadFile);
        } // end if
    } // End of the function
    var configArray = {autoscroll: "", autostart: "", backcolor: "", bufferlength: "", callback: "", captions: "", displayheight: "", enablejs: "", file: "", frontcolor: "", fsreturnpage: "", fullscreenmode: "", fullscreenpage: "", height: "", lightcolor: "", linkfromdisplay: "", linktarget: "", logo: "", overstretch: "", playerclip: "", repeat: "", rotatetime: "", showdigits: "", showeq: "", showfsbutton: "", showicons: "", shownavigation: "", shuffle: "", streamscript: "", thumbsinplaylist: "", transition: "", volume: "", width: ""};
    var fileElements = {title: "", author: "", link: "", image: "", id: "", category: "", start: ""};
} // End of Class
#endinitclip


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 4 chapter 15 angelic_scars BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 November 29th, 2006 08:36 AM
Pro PHP Chap 15 kgmcmillen Pro PHP 1 April 20th, 2006 02:38 PM
chapter 15 cart.php pink BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 July 18th, 2005 05:45 PM
PHP ( Cannot modify header information) squared_ring Beginning PHP 6 August 14th, 2004 05:29 AM
Ch. 12 userviewer.php -> modify Tachyon BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 May 18th, 2004 12:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.