0

我想做一个movieClip,它引用了另一个电影剪辑的移动。但是当我这样做时,它保持不动。这是我正在尝试做的示例代码

 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

你希望它如何移动?逐渐地,一次 1 个单位?如果是这样,请不要使用 while 循环,否则它会直接跳转到 300(x 位置)。

而是使用某种更新循环,例如输入帧侦听器:

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