View Full Version : Delay stuff
Sean611
07-18-2006, 10:58 AM
Hi guys, i face a problem when creating a delay time for my MC to move. Here is my scenario, i create a MC then i use for loop to duplicate it, then all of them will be assign the tween. i wan all of them come out 1 by 1 with actionscript, but i failed many times with different solution. Can anyone help me pls ......
i just need some coding to assign each MC created with different delay time so they will come out 1 by 1 like conveyer belt display. The output will look like this ( http://www.dynamicdrive.com/dynamicindex14/leftrightslide.htm ).
a pre-create number of MC is not my solution, because the number of MC always change. Thanks guys for the help.
mooska
07-18-2006, 11:15 AM
Dont think i got your right, but the thing you showed can be done easily, just put all your mcs into some container, and move it. If you mean moving mcs one after anotherimport mx.transitions.Tween;
import mx.transitions.easing.*;
function go(w:MovieClip){
clearInterval(out);
if(w==undefined){
return;
}
var t = new Tween(w, "_x", Bounce.easeOut, w._x, w._x+200, 20, false);
out = setInterval(go, 1000, a[++i]);
}
var a = [this.mc1, this.mc2, this.mc3];
var i = 0;
go(a[0]);this could be a good example
Sean611
07-19-2006, 02:16 AM
thank you so much mooska !! i will try the coding u gave me.
Sean611
07-19-2006, 03:36 AM
Mooska , actually i had try something like what u gave me.
First i use for loop to create the number of MCs then assign the tween yo it, then i use
delayInterval = setInterval (xxx(yyy),delaytime);
to get the delay. The delaytime will be keep increasing so that the following MC will not come out together with the earlier one.
But the output seem they did not wait the delay time and straight come out together with others. So is there any other solution ? Sorry for inconvenience and thanks for your time.
mooska
07-19-2006, 07:42 AM
Like I said, you can do this by placing your mcs into some containerimport mx.transitions.easing.*;
import mx.transitions.Tween;
this.createEmptyMovieClip("contener", 20);
for (i=0; i<5; i++) {
var mc = this.contener.attachMovie("mc", "mc"+i, i, {_y:i*40, _x:-100});
}
var t = new Tween(this.contener, "_x", Bounce.easeOut, this.contener._x, this.contener._x+300, 10, false);
Maybe Tween class is not perfect for your exmple, so
this.onEnterFrame = function(){
this.contener._x+=10;
}
should be enought.
Sean611
07-19-2006, 08:42 AM
Thanks for the help again . i will try the code u gave me.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.