all groups > flash actionscript > may 2006 >
You're in the

flash actionscript

group:

loading a movie from a php variable


loading a movie from a php variable Kevin0612
5/19/2006 7:21:22 PM
flash actionscript:
I have a web site that has publicity on it.

What I need to do in flash is to load a php file that will send me a link that
his chosen randomly and then in flash I have something like loadmovie(the link
from php)

Also at the end of each movie it need to reload that php file and load another
publicity.

What I have right now in my main flash is the fallowing

loadVars = new loadVars();
loadVars.load("pub.php");
loadVars.onLoad = function(success) {
if (success) {
pub.loadMovie(this.var2);
} else
{
pub.loadMovie("pub1.swf");
}
};
break;


and at the end of each pub I have this :

loadVars = new loadVars();
loadVars.load("pub.php");
loadVars.onLoad = function(success) {
if (success) {
_root.pub.loadMovie(this.var2);
} else
{
_root.pub.loadMovie("pub1");
}
};
break;

Right now the first movie load but when the first pub end it just loop at the
beginning and never load anything else
the only time something work was when I hard coded the link by using

this.loadMovie(my path here);
break;
Re: loading a movie from a php variable blemmo
5/20/2006 12:00:00 AM
Try placing a stop(), command on the last frame of the loaded movies, to avoid
replay while loading. Also, trace the loaded variable to see if it changes:
--
stop();
loadVars = new loadVars();
loadVars.load("pub.php");
loadVars.onLoad = function(success) {
if (success) {
trace(this.var2);
_root.pub.loadMovie(this.var2);
} else
{
_root.pub.loadMovie("pub1.swf");
}
};
--
If var2 is always the same, then Flash uses the cached php. To force a reload
instead of using the cached version, add a timestamp to the load command:
loadVars.load("pub.php?foo="+getTimer());
This way it's always a new URL, and Flash will load it again from the server.

The 'break' statements are useless here, they just do something in switch,
while or for statements.

hth,
blemmo
AddThis Social Bookmark Button