rctplcs
rctplcs

Reputation: 341

flash actionscript loadMovie

It works if I use

loadMovie("http://graph.facebook.com/100000108805716/picture", "imageLoader2");

but as I try to pass that link as variable from server this way:

loadVariables("http://paulius.shnaresys.com/suktukas/kodas.php", this, "GET"); loadMovie(draugas_1, "imageLoader");

It doesn't work. I know that the variable is passed as I can output in to text field. What do I do wrong?

Upvotes: 0

Views: 776

Answers (2)

shanethehat
shanethehat

Reputation: 15560

Have you tried using the example for the documentation? http://help.adobe.com/en_US/AS2LCR/Flash_10.0/00001319.html#390433

loadVariables("http://paulius.shnaresys.com/suktukas/kodas.php", this, "GET"); 
function checkVarsLoaded() {
    if(draugas_1 != undefined) {
        clearInterval(param_interval);
        loadMovie(draugas_1, "imageLoader");
    }
}
var param_interval = setInterval(checkVarsLoaded, 100);

Upvotes: 1

cwallenpoole
cwallenpoole

Reputation: 81988

Try this:

loadVariables("http://paulius.shnaresys.com/suktukas/kodas.php", this, "GET");
onEnterFrame = function()
{ 
     if( draugas_1 ) 
     { 
         loadMovie(draugas_1, "imageLoader");  
         delete this.onEnterFrame
     }
}

loadVariables happens asynchronously, which means that some time passes between the call of loadVariables and the return of the values which loadVariables retrieves. This means you need to wait until the variable exists before using it in loadMovie. The onEnterFrame is more or less the same way that the docs recommend. They use a setInterval, which technically makes fewer calls, but I personally prefer enterFrame to setInterval in AS2, especially in these circumstances.

The good news? Either way, you shouldn't have to wait too long that the user notices (or cares)

Upvotes: 3

Related Questions