码迷,mamicode.com
首页 > 其他好文 > 详细

[ActionScript] AS3代码实现曝光过度效果

时间:2015-09-04 14:18:18      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

 

 1 package 
 2 {
 3     import flash.display.Loader;
 4     import flash.display.SimpleButton;
 5     import flash.display.Sprite;
 6     import flash.events.Event;
 7     import flash.events.MouseEvent;
 8     import flash.geom.ColorTransform;
 9     import flash.net.URLRequest;
10     
11     /**
12      * ...
13      * @author FrostYen
14      */
15     public class ColorTransformExample extends Sprite
16     {
17         private var _ldr:Loader = new Loader();
18         private var _sp:Sprite = new Sprite();
19         private var _btn:Sprite = new Sprite();
20         private var _colorTransform:ColorTransform = new ColorTransform(1, 1, 1, 1, 255, 255, 255, 0);
21         private var _frame:int=15;//相当于影片剪辑动画的帧数
22         public function ColorTransformExample() {
23             
24             _ldr.load(new URLRequest("image/farewell-to-fall.jpg"));
25             _sp.transform.colorTransform = _colorTransform;
26             
27             _btn.graphics.beginFill(0x666666);
28             _btn.graphics.drawRect(0, 0, 100, 50);
29             _btn.graphics.endFill();
30             _btn.buttonMode = true;
31             _btn.x = 700;
32             _btn.y = 100;
33 
34             this.addChild(_btn);
35             this.addChild(_sp);
36             _sp.addChild(_ldr);
37             stage.frameRate = 36;//帧频
38             
39             _ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
40             _btn.addEventListener(MouseEvent.CLICK, onClick);
41         }
42         
43         private function onClick(e:MouseEvent):void 
44         {
45             addEventListener(Event.ENTER_FRAME, onEnter);
46         }
47         
48         private function onEnter(e:Event):void 
49         {
50             if (_colorTransform.redOffset > 0) {
51                 _colorTransform.redOffset -= 255/_frame;
52                 _colorTransform.greenOffset -= 255/_frame;
53                 _colorTransform.blueOffset -= 255/_frame;
54                 _sp.transform.colorTransform = _colorTransform;
55             }else {
56                 _colorTransform = new ColorTransform(1, 1, 1, 1, 255, 255, 255, 0);
57                 removeEventListener(Event.ENTER_FRAME, onEnter);
58             }
59         }
60         
61         private function onImageLoaded(e:Event):void 
62         {
63             
64         }
65     }
66     
67 }

 

[ActionScript] AS3代码实现曝光过度效果

标签:

原文地址:http://www.cnblogs.com/frost-yen/p/4781631.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!