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

flash actionscript

group:

Using MovieClip.onLoad



Using MovieClip.onLoad dpaultaylor
11/16/2006 6:33:46 PM
flash actionscript: Hi

I'm trying to load a dynamic image at a certain point in a timeline. I want to
pause at the point the loadMovie is actioned and test for when the jpeg has
loaded into the target movie clip before moving onto the next frame. I am using
Flash MX and the code is as follows :-

this.screenTop_mc.onLoad = function () {
gotoAndPlay("reveal");
}

this.screenBottom_mc.loadMovie("PDT_scratch.jpg");
this.screenTop_mc.loadMovie("PDT_reveal.jpg");

stop();

It seems simple but this does not work?
Re: Using MovieClip.onLoad kglad
11/16/2006 6:50:09 PM
it is simple and you're correct, it does not work. (onLoad applies to
movieclips that are in your library.)

if you use the moviecliploader class, it's just about as simple and does work:



mcl=new MovieClipLoader()
lo=new Object();
lo.onLoadInit=function(){
_root.gotoAndPlay("reveal");
}
mcl.loadClip("PDT_scratch.jpg",screenBottom);
mcl.addListener(lo);
mcl.loadClip("PDT_reveal.jpg",screenTop);
Re: Using MovieClip.onLoad dpaultaylor
11/16/2006 7:09:52 PM
Re: Using MovieClip.onLoad kglad
11/17/2006 12:00:00 AM
then you'll need to use preloader code. something like:



this.screenBottom_mc.loadMovie("PDT_scratch.jpg");
this.screenTop_mc.loadMovie("PDT_reveal.jpg");
preloadI=setInterval(preloadF,100);
function preloadF(){
bl=this.screenTop_mc.getBytesLoaded();
bt=this.screenTop_mc.getBytesTotal();
if(bl>0&&bl>=bt){
clearInterval(preloadI);
_root.gotoAndPlay("reveal");
}
}
AddThis Social Bookmark Button