A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] Checking when file has loaded (AS2 on CS3)

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    12

    resolved [RESOLVED] Checking when file has loaded (AS2 on CS3)

    Hey everyone,

    I am currently writing a site and one of the things it does is read variables from a database (by using the following code to access a php file which does the database lookup):

    loadVariablesNum ("loadvariables.php", 0, "POST");

    This works perfectly, however following this I load a number of images based on the variables that are returned. I am still quite new to flash so i don't think this is complicated, but i can't work out how to put an eventlistener, or something similar, so i can tell when loadvariables.php has finished loading. Then i can just load the relevant images in the oncomplete section (or the equivalent).

    I would be immensely grateful if anyone could point me in the right direction as i can't seem to work it out.

    Thanks very much everyone, i really appreciate your help,

    Dave

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Maybe you can adapt this...
    Code:
    // from Flash online docs
    loadVariablesNum("params.txt", 2);
    function checkParamsLoaded() {
     if (_level2.done == undefined) {
     trace("not yet.");
     } else {
     trace("finished loading. killing interval.");
     trace("-------------");
     for (i in _level2) {
     trace(i+": "+_level2[i]);
     }
     trace("-------------");
     clearInterval(param_interval);
     }
    }
    var param_interval:Number = setInterval(checkParamsLoaded, 100);
    
    // Params.txt includes the following text
    var1="hello"&var2="goodbye"&done="done"

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    12

    Question

    Dawsonk: Thanks so much, that makes perfect sense, simple when you know how! I do have one follow up question if you wouldn't mind? After the php file has loaded i run the following code to create movieclips for the relevant page images:

    Code:
    while(eval("_root.pagename" + currentpageid)!=0)
    {
    	currimg = eval("_root.pageimage" + currentpageid);
    	pagepictures.attachMovie("ExternalPicture", "PagePic" + currimg, pagepictures.getNextHighestDepth());
    	loadMovie("mainimages/" + portfolioid + "/" + currimg + ".jpg", pagepictures.PagePic + currimg);
    	currentpageid++;
    }
    This should then do everything i need, the problem is i attach the movie with name "PagePic" + currimg, which is fine, but when i need to loadMovie into it i'm not sure how to reference it as i don't think what i've put above (pagepictures.PagePic + currimg) is remotely right or possible in this situation.

    Any pointers would be massively appreciated, thank you so much for your help, it really is very much appreciated,

    Dave

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    	var extPic = pagepictures.attachMovie("ExternalPicture","PagePic"+currimg,pagepictures.getNextHighestDepth());
    	loadMovie("mainimages/"+portfolioid+"/"+currimg+".jpg", extPic);

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    Thanks for your quick reply, it's good to know that you can do that. I was trying to figure it out myself too and i ended up with:

    Code:
    	currimg = eval("_root.pageimage" + currentpageid);	
    	pagepictures.attachMovie("ExternalPicture", "PagePic" + currentpageid, pagepictures.getNextHighestDepth());
    	loadMovie("mainimages/" + portfolioid + "/" + currimg + ".jpg", pagepictures["PagePic" + currentpageid]);
    Which seems to do what i want. is there any reason to use what you wrote over what i wrote, or are they effectively the same (but without creating the var extPic).

    Thanks so much,

    Dave

  6. #6
    :
    Join Date
    Dec 2002
    Posts
    3,518
    same

  7. #7
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    You're a star, thanks so much for your help. While i'm at it, just to check, with regard to the original code to check if the file has loaded, this won't stop the next frame from loading will it, it will carry on as normal, just the code within checkparamsloaded won't run until it's loaded?

    I just wanted to make sure, although i'm pretty sure that's the case!

    Thanks so much for your help,

    Dave

  8. #8
    :
    Join Date
    Dec 2002
    Posts
    3,518
    right, it will carry on as normal

  9. #9
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    dawsonk: Thank you so, so much for your help, it has been absolutely invaluable, you are an absolute star. No doubt i will be back again soon when i hit up against another problem, but i just wanted to say thanks so much in meantime!

    Dave

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