• 【代码片段】ActionScript3.0 鼠标滑过水波波动


    package {
        import be.nascom.flash.graphics.Rippler;
        
        import flash.display.Bitmap;
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.events.MouseEvent;
    
        [SWF(backgroundColor="0x000000", frameRate="30", width="425", height="282")]
        public class Ripple extends Sprite
        {
        	// Embed an image (Flex Builder only, use library in Flash Authoring)
            [Embed(source="images/2.jpg")]
            private var _sourceImage : Class;
            
            private var _target : Bitmap;
            private var _rippler : Rippler;
            
            public function Ripple()
            {
                stage.scaleMode = StageScaleMode.NO_SCALE;
                stage.align = StageAlign.TOP_LEFT;
                
                // create a Bitmap displayobject and add it to the stage 
                _target = new Bitmap(new _sourceImage().bitmapData);
                addChild(_target);
                
                // create the Rippler instance to affect the Bitmap object
                _rippler = new Rippler(_target, 60, 6);
                
                // create the event listener for mouse movements
                stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
            }
            
            // creates a ripple at mouse coordinates on mouse movement
            private function handleMouseMove(event : MouseEvent) : void
            {
            	// the ripple point of impact is size 20 and has alpha 1
                _rippler.drawRipple(_target.mouseX, _target.mouseY, 20, 1);
            }
        }
    }
    

     注意事项:同目录下文件:Ripple.as(主要的代码都在里面)、Ripple.fla和Ripple.as(自己新建个文件导出下,注意文件名要相同)、images文件夹、be文件夹(存放Rippler.as第三方类库)

  • 相关阅读:
    Direct UI 思想阐述(好多相关文章)
    GetSystemTimeAsFileTime讲解(从1601年1月1日到目前经过的纳秒)
    WPF的消息机制
    CEdit 样式与消息 解析
    vcredist_x86.exe 静默安装方法
    iOS 开发问题集锦(一)
    EM算法详解
    BCP导入导出MsSql
    为什么不能在子类或外部发布C#事件
    HTML5 拖放及排序的简单实现
  • 原文地址:https://www.cnblogs.com/kojya/p/2514055.html
Copyright © 2020-2023  润新知