自编as3影片剪辑倒放类

先看效果:

实现原理:

1.编写mc加强类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package Functions{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.events.Event;
	public class MovieClip_adv extends MovieClip{
		//	定义倒放最终帧
		var endFrame:Number=1;
		public function MovieClip_adv(){
 
		}
		//任意位置到最后
		public function toEnd():void{
			this.upend(totalFrames);
		}
		//任意位置到开始
		public function toStart():void{
			this.upend(1);
		}
		//对单一过程由当前位置倒放或者顺放到任意目标位置
		public function upend(endFrame:Number):void{
			this.endFrame=endFrame;
			this.addEventListener(Event.ENTER_FRAME,back);
		}
		function back(event:Event):void{
			if(currentFrame==endFrame)
				this.removeEventListener(Event.ENTER_FRAME,back);
			else{
				//假如目前帧在最终帧之前
				if(currentFrame>=endFrame)
				this.prevFrame();
				else
				this.nextFrame();
			}
		}
	}
}

2.让mc链接到该加强类
mc

成功!源文件:下载地址

No Response to 自编as3影片剪辑倒放类 »

还没有任何评论。

Leave a Reply

Email address is not published

You should say a Chinese word to pass spam check. If you can not input Chinese, just copy 你好 and paste them into comment text box.