0

I want to make a movieClip which has a reference of another movie clip move. But when i do it it stays still. Here is an example code i am trying to do

 var movieClip1 = new movieClip();
 var movieClip2 = new movieClip();

movieClip1.ref = movieClip2;
movieClip1.x = 0;
movieClip2.x = 0;
addChild(movieClip1);
addChild(movieClip2);

while(movieClip1.x !=300){
movieClip1.x +=1;
// i want to make the reference of the clip move as well
movieClip1.ref.x = movieClip1.x;
}
4

1 に答える 1

0

How are you wanting it to move? Progressively, 1 unit at a time? If so Don't use a while loop or it will simply jump straight to 300 (x position).

Instead use some sort of update loop like an enter frame listener:

addEventListener(Event.ENTER_FRAME, Update);
function Update(e:Event):void
{
    mc1.x++;
    mc1.ref.x = mc1.x;
}
于 2013-01-09T12:22:44.793 に答える