[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);
}
}
}
[ActionScript 3.0] AS3 拖拽混动效果之一的更多相关文章
- [ActionScript 3.0] AS3 用于拖动对象时一次一页的缓动
package com.fylibs.components.effects{ import com.tweener.transitions.Tweener; import flash.display. ...
- [ActionScript 3.0] AS3 用于拖动对象时跟随鼠标的缓动效果
package com.fylibs.components.effects { import flash.display.DisplayObject; import flash.events.Even ...
- [ActionScript 3.0] as3处理xml的功能和遍历节点
as3比as2处理xml的功能增强了N倍,获取或遍历节点非常之方便,类似于json对像的处理方式. XML 的一个强大功能是它能够通过文本字符的线性字符串提供复杂的嵌套数据.将数据加载到 XML 对象 ...
- Android4.0 Launcher拖拽原理分析
在Android4.0源码自带的Launcher中,拖拽是由DragController进行控制的. 1) 先来看看类之间的继承关系 2)再来看看Launcher拖拽流程的时序图 1.基本流程: ...
- Angular 2.0 文本拖拽
基于Angular7.1和TypeScript实现 Html代码 <div style="padding-left: 0px;"> <div id='conten ...
- [ActionScript 3.0] AS3.0 动态加载显示内容
可以将下列任何外部显示资源加载到 ActionScript 3.0 应用程序中: 在 ActionScript 3.0 中创作的 SWF 文件 — 此文件可以是 Sprite.MovieClip 或扩 ...
- Android 可拖拽的GridView效果实现, 长按可拖拽和item实时交换
转帖请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/17718579),请尊重他人的辛勤劳动成果,谢谢! 在And ...
- 用H5自带拖拽做出购物车效果的作业题
效果描述: 图片代表物品,图片在有宽高的div上方显示,把图片拖放到设置好的div里面,并且在div里面显示图片的信息:价格,物品名,数量.如果拖放有重复,只是在div里面让物品的数量加1,最后计算出 ...
- [ActionScript 3.0] AS3.0 本机鼠标指针
Flash Player 10.2添加了内置的本机鼠标指针(native mouse cursor)支持,虽然在之前的版本里我们可以侦听MouseEvent事件来模拟鼠标指针,但是在有了原生的本机鼠标 ...
随机推荐
- browser-ua
故事还得从头说起,最初的主角叫NCSA Mosaic,简称Mosaic(马赛克),是1992年末位于伊利诺伊大学厄巴纳-香槟分校的国家超级计算机应用中心(National Center for Sup ...
- sqlserver服务器常用的性能计数器
sqlserver服务器常用的性能计数器,在此标记. 性能对象 计数器 说明 Processor %Processor Time %Privileged Time 建议值:持续低于80 建议值:持续低 ...
- String equals的技巧
把常量放到前面,可以避免null指针问题 System.out.print("".equals(null)); String abc = null; System.out.prin ...
- AJAX状态值与状态码
在<Pragmatic Ajax A Web 2.0 Primer > 0: (Uninitialized) the send( ) method has not yet been inv ...
- sql 操作,
SELECT * FROM dbo.tbl_Web_Photos AS pt LEFT JOIN dbo.tbl_Web_Friends AS fd ON pt.user_email=fd.AddEm ...
- (转)关于List中FindAll用法的一些简单示例
本文转载自:http://blog.csdn.net/luoxufeng/article/details/6925982 using System; using System.Collections. ...
- freeswitch编译
编译1.6版本的话,debian的包就太老,需要添加新源 echo "deb http://files.freeswitch.org/repo/deb/debian/ jessie main ...
- ADB工具 获取ROOT权限及复制文件方法
adb push d:\tm3_sqlit.db data/zouhao/tm3_sqlit.dbadb pull data/zouhao/tm3_sqlit.db d:\tm3_sqlit.db a ...
- 【转】SQL SERVER CLR存储过程实现
最近做一个项目,需要做一个SQL SERVER 2005的CLR的存储过程,研究了一下CLR的实现.为方便以后再使用,在这里总结一下我的实现流程,也供对CLR感兴趣但又不知道如何实现的朋友们做一下参考 ...
- 2014 年10个最佳的PHP图像操作库
2014 年10个最佳的PHP图像操作库 Thomas Boutell 以及众多的开发者创造了以GD图形库闻名的一个图形软件库,用于动态的图形计算. GD提供了对于诸如C, Perl, Pytho ...