[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事件来模拟鼠标指针,但是在有了原生的本机鼠标 ...
随机推荐
- Asp.net MVC的actionlink到Areas里action
<li>@Html.ActionLink("Home", "Index", "Home", new { area = " ...
- unity中的欧拉角
unity中欧拉角用的是heading - pitch -bank系统(zxy惯性空间旋转系统):当认为旋转顺序是zxy时,是相对于惯性坐标系旋转.当认为旋转顺序是yxz时,是相对于物体坐标系旋转. ...
- jquery操作html data-* 属性的坑
- SQL Server锁、闩等资源的阻塞诊断---osql/sqlcmd,sp_blocker_pss80
osql/sqlcmd 工具是一个 SqlServer的命令提示符工具,我们可以使用它运行 Transact-SQL 语句和脚本文件.该工具所在目录:C:\Program Files\Mi ...
- 你了解System.out.println()的真正含义吗?
在Java编程中,我们常常用 System.out.println(); 来输出字符串,也许我们都已经猜到println()是方法名,但System是什么,out又是什么呢? 其实System是jav ...
- linux下openoffice的安装和启动
下载openoffice的安装包(注意选择合适的安装包): http://www.openoffice.org/download/archive.html 一.安装openOffice1.使用tar ...
- bootstrapDialog插件集成datatables插件遇到的异常
最近项目中,涉及到很多细分领域的东西,有好些目前还没有详细的方案.这是后话,当前起步阶段,我要把握技术路线,搭建基础架构!其中,有好几个地方都用到模态框(Modal), 虽然Bootstrap框架里面 ...
- Struts 1.3(第一例) - Login
本想跳过直接学Struts 2的,想想,还是先学Struts 1,万一到时去那个公司,人家用的是1,那还是要学,以及了解下1与2的区别在哪里. 上例子,很简单的一个网上login例子,再思考下Stru ...
- bzoj4637: 期望
Description 在米国有一所大学,名叫万国歌剧与信息大学(UniversalOperaandInformaticasUniversity).简称UOI大学.UO I大学的建筑与道路分布很有趣, ...
- golang的验证码相关的库
识别库 https://github.com/goghcrow/capture_easy 生成验证码的库 https://github.com/hanguofeng/gocaptcha 生成图片水印 ...