zoukankan      html  css  js  c++  java
  • [ActionScript] AS3代码实现曝光过度效果

     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 }
  • 相关阅读:
    Python量化分析,计算KDJ
    Ubuntu16.04安装Python3.6 和pip(python3 各版本切换)
    使用docker加载已有镜像安装Hyperledger Fabric v1.1.0
    Ubuntu 16.04将左侧面板置于底部
    解决Flask局域网内访问不了的问题
    Ubuntu 16.04 安装Go 1.9.2
    Ubuntu16.04下安装Hyperledger Fabric 1.0.0
    Ubuntu 16.04安装Docker-CE
    用Python抓取网页并解析
    图解python中赋值、浅拷贝、深拷贝的区别
  • 原文地址:https://www.cnblogs.com/frost-yen/p/4781631.html
Copyright © 2011-2022 走看看