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. C#中的static、readonly与const的比较

    C#中有两种常量类型,分别为readonly(运行时常量)与const(编译时常量),本文将就这两种类型的不同特性进行比较并说明各自的适用场景. 工作原理     readonly为运行时常量,程序运 ...

  2. sqlServer 存储过程执行遇到的问题及解决方案

    1.EXEC 执行Sql语句被截断的问题: Sql语句: SET @sqlSel='SELECT '+@sqlField+', SUM(ISNULL(b.customsTariff_Sup,0))AS ...

  3. android中两种方式打开网页

    一.你要打开一个网页你可以自己写一个webview,在自己的程序中就可以打开. wv = (WebView) findViewById(R.id.webView1); wv.getSettings() ...

  4. Junit手动/自动加载spring配置文件

    分配置文件在classpath下和web-inf下两种情况的加载: ApplicationContext context = new FileSystemXmlApplicationContext(& ...

  5. Js RegExp对象

    1 语法 1.1 直接量语法 /pattern/attributes 1.2 创建RegExp对象 new RegExp(pattern, attributes) 1.3 说明 pattern是正则表 ...

  6. Redis 利用锁机制来防止缓存过期产生的惊群现象-转载自 http://my.oschina.net/u/1156660/blog/360552

    首先,所谓的缓存过期引起的“惊群”现象是指,在大并发情况下,我们通常会用缓存来给数据库分压,但是会有这么一种情况发生,那就是在一定时间 内生成大量的缓存,然后当缓存到期之后又有大量的缓存失效,导致后端 ...

  7. .NET使用OpenSSL生成的pem密钥文件

    NET要使用OpenSSL生成的pem密钥文件,网上资料很少(http://www.faqs.org/rfcs/rfc1421.html,RFC1421文件又老长老长),仅有的资料还是有错误的,所以今 ...

  8. read,for,case,while,if简单例子

    Read多用于从某文件中取出每行进行处理 $ cat read.sh #!/bin/bash echo "using read" cat name.txt | while read ...

  9. KB975517 "The update does not apply to your system"

    https://www.manageengine.com/products//desktop-central/patch-management/Windows-Vista-Ultimate-Editi ...

  10. TextBox(只允许输入字母或者数字)

    实现如下: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System ...