这里的 AS3 新手......非常困惑,请善待;)
我有一个 MovieClip (rozette),其中包含一个 MovieClip (circle) 的 7 个实例。circle 包含一个动画,我想在 rozette 中连续播放它的每个实例。
问题 - 我需要使用数组吗?使用 eventListener 是最好的方法吗?如果是这样,我如何为数组中的每个项目创建一个事件监听器?我在听什么样的活动?
非常感谢。吉
这里的 AS3 新手......非常困惑,请善待;)
我有一个 MovieClip (rozette),其中包含一个 MovieClip (circle) 的 7 个实例。circle 包含一个动画,我想在 rozette 中连续播放它的每个实例。
问题 - 我需要使用数组吗?使用 eventListener 是最好的方法吗?如果是这样,我如何为数组中的每个项目创建一个事件监听器?我在听什么样的活动?
非常感谢。吉
您可以在此处看到作为答案给出的一些选项:
基本上我认为你想要一个数组和一个计数器,每次调用“playNext”函数时,你应该增加计数器并从数组中拉下一个影片剪辑。这意味着数组中元素的顺序将决定它们的播放顺序。例如:
private var myArray:Array = [mc1,mc2,mc3]; //list all the movieclip instance names here
private var counter:Number = 0; //start off on the first element, arrays in AS3 start at 0
//Play the next clip
private function playNext():void {
//Check that we're not at the end of the list, if so just return/stop
if(counter>myArray.length-1)
return;
//grab the next clip
var curClip:MovieClip = myArray[counter] as MovieClip;
//increment the counter for next time
counter++;
//when the last frame gets hit call this function again
curClip.addFrameScript(curClip.totalFrames-1, playNext);
//play the clip
curClip.play();
}
从 Main 类的构造函数中,您可能希望调用一次 playNext() 以使事情顺利进行。
import com .greensock.*;
import com. greensock.easing.*;
var s1:b1=new b1();
var s2:b2=new b2();
var s3:b3=new b3();
var r1:Array = new Array();
r1.push(s1);
r1.push(s2);
r1.push(s3);
function ff (){
var i = 0;
while (i < r1.length) {
r1[i].visible=false
r1[0].visible=true
addChild(r1[i]);
i++;
}
TweenMax.staggerTo(r1, 0.4, {visible:true},0.2);
}
bb.addEventListener(MouseEvent.CLICK,cliki4x);
function cliki4x(e:Event):void{
ff ();
}