flash - Loading image twice via Actionscript3? -


i'm trying use infinite scroll as3 discuss in this question. i'm developing using flashcs5 ide.

the absolutely last thing need load large background image ("header_bg_vert.jpg") externally after rest of movie has loaded, instead of requiring entirety of animation load beforehand (or preloading header animation in).

my as3 below. "infinite loop" works placing 2 copies of same seamless image end-to-end, moving second image front after scrolls off screen -- currently, code displays 1 copy of image. what's wrong it? also, best way of accomplishing this?

many thanks.

stop();  //load bg image var request:urlrequest = new urlrequest("header_bg_vert.jpg"); var s1:loader = new loader(); var s2:loader = new loader();  s1.contentloaderinfo.addeventlistener(progressevent.progress, loadprogress); s1.contentloaderinfo.addeventlistener(event.complete, loadcomplete);  s2.contentloaderinfo.addeventlistener(progressevent.progress, loadprogress); s2.contentloaderinfo.addeventlistener(event.complete, loadcomplete);   function loadprogress(event:progressevent):void { var percentloaded:number = event.bytesloaded/event.bytestotal; percentloaded = math.round(percentloaded * 100); trace("loading: "+percentloaded+"%"); } function loadcomplete(event:event):void { trace("complete"); }  s1.load(request); s2.load(request);  //the speed of scroll movement. var scrollspeed:uint = 1;  //originally, added 2 instances of movie clip onto stage. //var s1:scrollbg = new scrollbg(); //var s2:scrollbg = new scrollbg();  addchild(s1);  addchild(s2); setchildindex(s1, 0); setchildindex(s2, 0); //this positions second movieclip next first one. s1.y = 0; s2.y = s1.height;  //adds event listener stage. stage.addeventlistener(event.enter_frame, movescroll);   //this function moves both images left. if first , second  //images goes pass left stage boundary gets moved  //the other side of stage.  function movescroll(e:event):void{ s1.y -= scrollspeed;   s2.y -= scrollspeed;    if(s1.y <= -s1.height){ s1.y = s1.height - scrollspeed; }else if(s2.y <= -s2.height){ s2.y = s2.height - scrollspeed; } } 

apparently displays both copies on top of each other. happens because flash player not know how tall s1 before loaded. should position images within loadcomplete()


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -