zoukankan      html  css  js  c++  java
  • [ActionScript 3.0] AS3 拖拽混动效果之一

    package
    {
        import flash.display.Loader;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.net.URLRequest;
        
        /**
         * @author Frost.Yen
         * @E-mail 871979853@qq.com
         * @create 2015-11-17 上午10:20:30
         *
         */
        [SWF(width="1920",height="1080")]
        public class EaseingEffect extends Sprite
        {
            private var _ldr:Loader = new Loader();
            private var _container:Sprite = new Sprite();
            private var _downX:Number;//按下照片墙的x坐标
            private var _moveX:Number;//移动照片墙的x坐标
            private var _offsetX:Number;//水平移动偏移量
            private var _isDown:Boolean;
            public function EaseingEffect()
            {
                initViews();
                initEventListeners();
            }
            private function initViews():void
            {
                this.addChild(_container);
                _container.addChild(_ldr);
                _ldr.load(new URLRequest("assets/photowall.png"));
            }
            private function initEventListeners():void
            {
                _ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded);
                _container.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
                this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
            private function onLoaded(e:Event):void
            {
                
            }
            private function onDown(e:MouseEvent):void
            {
                _isDown = true;
                _downX = mouseX;
                stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
                stage.addEventListener(MouseEvent.MOUSE_UP, onUp);
            }
            private function onEnterFrame(e:Event):void
            {
                _offsetX = _offsetX * 0.900000;
                _container.x = _container.x + _offsetX;
                if (_container.x < 1920 - _container.width )
                {
                    _container.x = 1920 - _container.width ;
                } 
                if (_container.x > 0)
                {
                    _container.x = 0;
                }
            }
            private function onMove(e:MouseEvent):void
            {
                if (_isDown) {
                    _moveX = mouseX;
                    _offsetX = _moveX - _downX;
                    _offsetX = _offsetX / 20;
                }
            }
            private function onUp(e:MouseEvent):void
            {
                _isDown = false;
                stage.removeEventListener(MouseEvent.MOUSE_UP, onUp);
                stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
            }
        }
    }
  • 相关阅读:
    MyBatis 配置文件 用户密码加密存储
    MyBatis 实例
    mybatis 入门搭建
    文件上传
    struts 结果类型
    Struts 拦截器
    log4j
    Struts Action 控制器
    Struts
    四、常用的Maven命令
  • 原文地址:https://www.cnblogs.com/frost-yen/p/4970949.html
Copyright © 2011-2022 走看看