dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: creating "wait state" for loadVariables

  1. #1
    Member
    Join Date
    Jun 2005
    Location
    dallas, tx
    Posts
    54

    creating "wait state" for loadVariables

    i'm loading in variables from a php file, but they are not loading in fast enough so there are a lot of undefined variables by the time my movie gets to the frame where they are actually being used.

    i have the Flash MX Bible and in it, they talk about it. it says in there to add another variable at the end of the text like success=1 or something like that, and creating a loop to check when it has been loading and then leaving the loop.

    i tried that with the following code:
    Code:
    loadVariables("../images/comingsoon/comingsoon.txt", this);
    while(1) {
    	if(loaded == 1) {
    		break;
    	}
    }
    but when i test it, i get a message saying that the script is causing flash to run very slow and that i have to abort the script. so, this obviously isn't the best way to do it

    if anyone has some examples or a better way of doing something like that, i'd appreciate the help!

    Thanks

  2. #2
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    A while loop will run until it is finished and not let the movie continue to the next "frame" and I think that load-actions aren't actually issued until inbetween "frames".

    If you publish for player 6 or later I would recommend you to look at the LoadVars object instead. It has an event that will fire when the variables are loaded. It will even tell you if the file it's supposed to load variables from was found or not. No need to use those extra vars and frame-loops/onClipEvent(data).

    It works like this:
    Code:
    myVars = new LoadVars();
    myVars.onLoad = function(success)
    {
        if(success)
        {
            // The file was found and the variables are loaded so start proccessing them here
        } else {
            // The file was not found so either do some error checking or die silently.
        }
    }
    myVars.load("../images/comingsoon/comingsoon.txt");
    /Mirandir

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center