3 Replies Latest reply on Feb 1, 2007 9:06 AM by kglad

timer problem

I can't get the timer to work with array notation of MC.

left=function (){

mcc1._x+=10; //works fine

//this["mcc1"]._x+=10; //fails with array notation
//this._parent["mcc1"]._x+=10;
}
var ww:Number=setInterval(left,200);
• 1. Re: timer problem
your refrence to "this" in left() isn't what you think it is. because you're using setInterval() to call left and you're not sending a parameter to define "this", it's undefined. you can use:

• 2. Re: timer problem
Hi,

I can do it this way as well.
What I wanted to know was about moving more than 1 dynamic object at different times.
Here I move 2 objects at the same time and it works. If I wanted to distinguish the 2 objects and say move 1 more than the other or stop 1 and don't stop the other it is difficult.

var ww:Number;

left=function (mc1:MovieClip,a:Number,cc:Number){

//trace(a);
b=mc1._x;
mc1._x+=10;
//trace(b);
if (b-a>=50)
{
for(i=1;i<3;i++)
{
clearInterval(ss );
}
}
//trace(b);
//this["mcc1"]._x+=10;
}
//var ww:Number=setInterval(left,200,this["mcc"+1]);
var ww2:Number;
var ss:Array=new Array();
ss[0]=0;

for(i=1;i<3;i++)
{

ww2=setInterval(left,200,this["mcc"+i],this["mcc"+i]._x,ww2);
ss
=ww2;

}
• 3. Re: timer problem
set attributes or properties of each object that stores the values you need like the speed of movement or the stop condition. you then only need to pass the object and use its properties in left().