你也可以这样使用:
public function playInReverse(){
your_mc.stop(); //your_mc is the movieclip/sprite you want to play in reverse
this.addEventListener(Event.ENTER_FRAME, reverseEvent);
}
public function playNormally(){
this.removeEventListener(Event.ENTER_FRAME, reverseEvent);
your_mc.play();
}
private function reverseEvent(evt:Event){
//if your_mc is on the first frame, go to the last frame. Otherwise, go to previous frame.
if(your_mc.currentFrame == first_frame){ //first_frame is the number or name of the first frame of the animation
your_mc.gotoAndStop(last_frame); //last_frame is the number or name of the last frame of the animation
}else{
your_mc.prevFrame(); //go to the previous frame
}
}
因此,当您希望电影剪辑/精灵反向播放时,您只需调用 playInReverse(); 并且当您希望它正常播放时,您调用 playNormally(); .
此外,您可以通过向 playNormally() 和 playInReverse() 添加参数来指定要使用的影片剪辑/精灵。当使用这些函数时,您可以使用 String 作为参数指定对象,并为其提供动画的开始和最后一帧编号(例如:playInReverse("your_mc_1", 1, 100); (或) playInReverse("your_mc_2", 14, 37); ):
private var reversing_mc:String;
private var first_frame:int;
private var last_frame:int;
public function playInReverse(the_mc:String, first_frame_number:int, last_frame_number:int){
this[the_mc].stop();
reversing_mc = the_mc;
first_frame = first_frame_number;
last_frame = last_frame_number;
this.addEventListener(Event.ENTER_FRAME, reverseEvent);
}
public function playNormally(the_mc:String){
this.removeEventListener(Event.ENTER_FRAME, reverseEvent);
this[the_mc].play();
}
private function reverseEvent(evt:Event){
if(your_mc.currentFrame == first_frame){
this[reversing_mc].gotoAndStop(last_frame);
}else{
this[reversing_mc].prevFrame();
}
}