all groups > flash actionscript > august 2005 >
You're in the

flash actionscript

group:

attachmovie quesion


attachmovie quesion posterboy
8/10/2005 10:06:19 PM
flash actionscript:
how do i load a movie clip after a certain amount of time has elapsed?

i have been playing with onEnterFrame and setInterval with no results.

basically i want to attach a movie in certain location after about a
half-second upon loading of a frame.

thanks > mark
Re: attachmovie quesion lumeeguvnor
8/10/2005 10:19:03 PM
function loader() {
_root.createEmptyMovieClip("holder",1);
holder.attachMovie("yourMovie",yourMovie,1);
clearInterval(loadIt)
}
Re: attachmovie quesion posterboy
8/10/2005 10:27:49 PM
thank you. after fiddling around this script worked also...

attachMovie("patch_level1_mc", "patch_level1_mc", 2, {_x:510, _y:350});
patch_level1_mc._alpha = 0;
attachPatch = function () {
patch_level1_mc._alpha = 100;
}
setInterval(attachPatch, 500);
clearInterval();
Re: attachmovie quesion mandingo
8/10/2005 10:48:50 PM
it is probably a better idea to ensure that the interval has an id... either as
given by lummeeguvnor or else an object... this will ensure the correct
interval is removed...

with the code you provided, you are still attaching the instance straight away
just setting it's alpha to zero... that isn't what you asked for.

try something like this:

this.intervalId = setInterval(attachPatch= function(patch,clip){
intervalCounter++;
clip.attachMovie(patch,patch,intervalCounter);
clearInterval(clip.intervalId)
},500,"patch_level1_mc",this);


I think that is the right code.

cheers,
Re: attachmovie quesion posterboy
8/10/2005 10:55:36 PM
Re: attachmovie quesion mandingo
8/10/2005 11:09:47 PM
Re: attachmovie quesion NSurveyor
8/11/2005 12:21:21 AM
Just a comment... I don't see the need for intervalCounter seeing that the
interval is only called once...And since your putting your function directly
inside the setInterval there's no point in naming it... personally I would make
the function outside the setInterval for reading purposes.


And if you want to make a method for doing this, you could do something like:

MovieClip.prototype.waitAttachMovie = function(delay, idName, newName, depth,
initObject){
if(!this.intervals){
this.intervals = [];
this.attachPatch = function(mc,idName,newName,depth,initObject,idLoc)){
mc.attachMovie(idName,newName,depth,initObject);
clearInterval(mc.intervals[idLoc]);
}
}
var idLoc = this.intervals.length;

this.intervals.push(setInterval(this.attachPatch,500,this,idName,newName,depth,
initObject,idLoc));
}

//then use:

this.waitAttachMovie(500,"patch_level1_mc", "patch_level1_mc", 2, {_x:510,
_y:350});

but of course if you're only doing it once, the old code worked fine...

BTW, I haven't tested the code, but it mite work.
AddThis Social Bookmark Button