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);
}
}
}

[ActionScript 3.0] AS3 拖拽混动效果之一的更多相关文章

  1. [ActionScript 3.0] AS3 用于拖动对象时一次一页的缓动

    package com.fylibs.components.effects{ import com.tweener.transitions.Tweener; import flash.display. ...

  2. [ActionScript 3.0] AS3 用于拖动对象时跟随鼠标的缓动效果

    package com.fylibs.components.effects { import flash.display.DisplayObject; import flash.events.Even ...

  3. [ActionScript 3.0] as3处理xml的功能和遍历节点

    as3比as2处理xml的功能增强了N倍,获取或遍历节点非常之方便,类似于json对像的处理方式. XML 的一个强大功能是它能够通过文本字符的线性字符串提供复杂的嵌套数据.将数据加载到 XML 对象 ...

  4. Android4.0 Launcher拖拽原理分析

    在Android4.0源码自带的Launcher中,拖拽是由DragController进行控制的. 1) 先来看看类之间的继承关系 2)再来看看Launcher拖拽流程的时序图   1.基本流程: ...

  5. Angular 2.0 文本拖拽

    基于Angular7.1和TypeScript实现 Html代码 <div style="padding-left: 0px;"> <div id='conten ...

  6. [ActionScript 3.0] AS3.0 动态加载显示内容

    可以将下列任何外部显示资源加载到 ActionScript 3.0 应用程序中: 在 ActionScript 3.0 中创作的 SWF 文件 — 此文件可以是 Sprite.MovieClip 或扩 ...

  7. Android 可拖拽的GridView效果实现, 长按可拖拽和item实时交换

    转帖请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/17718579),请尊重他人的辛勤劳动成果,谢谢! 在And ...

  8. 用H5自带拖拽做出购物车效果的作业题

    效果描述: 图片代表物品,图片在有宽高的div上方显示,把图片拖放到设置好的div里面,并且在div里面显示图片的信息:价格,物品名,数量.如果拖放有重复,只是在div里面让物品的数量加1,最后计算出 ...

  9. [ActionScript 3.0] AS3.0 本机鼠标指针

    Flash Player 10.2添加了内置的本机鼠标指针(native mouse cursor)支持,虽然在之前的版本里我们可以侦听MouseEvent事件来模拟鼠标指针,但是在有了原生的本机鼠标 ...

随机推荐

  1. apache使用ssl数字证书

    apache配置: <VirtualHost *:443> ServerName web.p2 .com ProxyPreserveHost On ProxyRequests Off SS ...

  2. 【Reporting Services 报表开发】— 交互式报表

    我们知道,界面是人与系统间的对话方式,当使用者面对的是冷冰冰的界面,不但会造成使用者对于系统的热情减低,也会因为不便而产生诸多抱怨.尤其像报表时企业内几乎每日都会使用到的工具,因此,如何让使用者可以再 ...

  3. HttpClient简介 post get -转自ibm

    HttpClient简介 HTTP 协议可能是现在 Internet 上使用得最多.最重要的协议了,越来越多的 Java 应用程序需要直接通过 HTTP 协议来访问网络资源.虽然在 JDK 的 jav ...

  4. WCF学习心得----(四)服务承载

    WCF学习心得----(四)服务承载 这一章节花费了好长的时间才整理个大概,主要原因是初次接触这个东西,在做练习实践的过程中,遇到了很多的问题,有些问题到目前还没有得以解决.所以在这一章节中,有一个承 ...

  5. Load an X509 PEM file into Windows CryptoApi

    http://stackoverflow.com/questions/1231178/load-an-x509-pem-file-into-windows-cryptoapi I discovered ...

  6. asp.net mvc 页面传值的方法总结

    转自:http://msprogrammer.serviciipeweb.ro/2012/01/15/usual-methods-to-transfer-data-from-page-to-page- ...

  7. php时间日期处理

    php日期函数: 首先想到的就是date(),time(),strtotime(),mktime() strtotime() strtotime()函数用于将英文文本字符串表示的日期转换为时间戳,为 ...

  8. Centos7 + Windows7 双系统

    以前装双系统只要先装Windows7,然后再装Centos7的话,grub会自动添加原有的Windows7系统.不过在新的Centos7中需要手动修改. 步骤如下 $ sudo vi /etc/gru ...

  9. centos 连不上网

    ifc-eth0 里面要加DNS1=192.168.1.1 一定是DNS1这样的,不要是DNS

  10. JS URL 使用base64加密与解密

    JS编码方式: <script type="text/javascript"> document.write(encodeURI("http://www.w3 ...