as3 TweenMax TweenLite方法
TweenLite.to(mc, 1.5, {x:100});
里面的mc指所作用的对象,1.5指运动的时间,{x:100} 表示mc的x属性变化,最终停下来时x的值为100. (即mc从当前位置,经过1.5秒,匀速移动到x=100的位置)
TweenLite.from(mc, 1.5, {x:100})
里面的mc指所作用的对象,1.5指运动的时间, 这里是指,mc从当前位置,经过1.5秒, 从x=100的位置移动到当前mc所在的位置。“注意与上面的区别,他们恰好相反”)
下面我们以上面的TweenLite.to() 来讲解相关属性:
TweenLite.to()
TweenLite.from()
//返回的都是TweenLite类型 TweenLite.to(mc, 1.5, {x:100});
//我们还可以在{}里加些其他相关的属性
下面有delay属性 其表示 延迟delay时间后才发生Tween :
TweenLite.to(mc, , {x:, delay:});
//表示需要经过2秒,mc才执行发生移动
我们还可以在{}加入alpha、 ease(缓动) onComplete(所调用的方法名)等属性:
TweenLite.to(mc, 1.5, {x:, ease:Elastic.easeOut, delay:0.5, onComplete:myFunction});
function myFunction():void
{
trace("tween finished");
} /*上面的 ease:Elastic.easeOut是缓动类的一种类型 onComplete:myFunction 表示tween执行完后就会调用myFunction方法(即执行完Tween后,紧接着就调用myFunction方法,)。*/
TweenLite还有一方法,如:pause(), resume(), reverse(), restart()
pause() 表示暂停
resume() 表示继续播放缓动
restart() 表示重头开始播放缓动
reverse() 表示按与原方向相反的方向缓动(例如:缓动了2秒后,调用该方法,就会经过相同的时间(2秒)按原路返回)
下面是一个对各个属性进行验证的小例子:
start_btn是开始按钮,即按下它才会执行缓动
btn 按钮是对一些方法的验证 ,你可以改变里面的相关方法进行验证 如将 tween.reverse(); 改成tween.resume();
import com.greensock.*;
import com.greensock.easing.*;
var isPause:Boolean;
var tween:TweenLite;
btn.enabled = false;
start_btn.addEventListener(MouseEvent.CLICK,begin);
btn.addEventListener(MouseEvent.MOUSE_DOWN,onDown);
function begin(e:MouseEvent)
{
btn.enabled = true;
tween = TweenLite.from(mc,,{x:,y:,alpha:0.5,delay:,onComplete:completeIt});
}
function completeIt()
{ trace("缓动执行完毕,开始调用此方法");
trace(tween);
//TweenLite类型 } function onDown(e:Event):void
{
if (isPause==false)
{
tween.pause();
isPause = true;
}
else
{
tween.reverse();
isPause = false;
} }
onComplete : Function – 缓动结束时执行的函数。
onCompleteParams : Array – 给 onComplete 参数指定的函数传递参数 (可选的)
stageBallDowntween = TweenLite.to(nowStageDownBall,ballDownPerTime*(2-getSamePipOtherBallInfo_arr[1]),{rotation:360,x:e.target.x,y:e.target.y-stageBallHeight*getSamePipOtherBallInfo_arr[1],onComplete:completeIt,onCompleteParams:[]});
TweenLite可选属性:overwrite
overwrite属性 : 默认值是 2 即 auto
一般用法:
TweenLite.to(mc, , {x:, overwrite:});
//推荐 使用这种, 2 代表的是模式2 即AUTO模式 也是默认值 // 或者 TweenLite.to(mc, , {x:, overwrite:true});
//在使用模式时 ,需要初始化 即: OverwriteManager.init(2)
/* 里面的模式2 只是起个初始化作用, 你可以将其修改为其他的模式,但是上面的初始化必不可少,否则无效(无效则用默认模式2) 。
模式修改是在overwrite里进行的。*/ //例如: OverwriteManager.init(2)
//初始化
TweenLite.to(btn, 1, {x:100, overwrite:1});
//初始化模式为2,现在修改为1
TweenLite.to(mc, 1.5, {x:, y:, onComplete:myFunction, ease:Strong.easeOut});
TweenMax.to(mc, 1.5, {x:, y:, onComplete:myFunction, ease:Strong.easeOut});
var myTimeline:TimelineLite = new TimelineLite();
myTimeline.append( new TweenLite(mc, , {x:}) );
//添加进myTimeline;
myTimeline.append( new TweenLite(mc, , {y:}) );
myTimeline.append( new TweenMax(mc, , {tint:0xFF0000}) );
var myTimeline:TimelineLite = new TimelineLite({paused:true});
myTimeline.append( new TweenLite(mc, , {x:}) );
myTimeline.append( new TweenLite(mc, , {y:}) );
myTimeline.append( new TweenMax(mc, , {tint:0xFF0000}) ); menu.addEventListener(MouseEvent.ROLL_OVER, overHandler);
menu.addEventListener(MouseEvent.ROLL_OUT, outHandler); function overHandler(event:MouseEvent):void
{
myTimeline.play();
} function outHandler(event:MouseEvent):void
{
myTimeline.reverse();
}
var myTimeline:TimelineLite = new TimelineLite(); //在时刻为1秒的地方插入 tween运动,即第一秒结束后才运动
myTimeline.insert( new TweenLite(mc, , {x:}), );
//提前1.5秒发生tween运动;
myTimeline.append( new TweenLite(mc, , {y:}), -1.5);
// 为4秒时刻增加标签 spin;
myTimeline.addLabel("spin", ); //在spin标签处添加tween动画;
myTimeline.insert( new TweenLite(mc, , {rotation:""}), "spin");
myTimeline.insertMultiple( TweenMax.allFrom(myArrayOfSprites, , {y:"-100", autoAlpha:}) ); TweenLite.delayedCall(, myFunction, [myParam1, myParam2]);
/*表示经过2秒后执行myFunction()方法,[myParam1, myParam2是该方法的参数*/ TweenLite.to(mc, , {x:""});
//在原坐标的基础上增加100像素 注意与x:100的区别
//如果传入的参数是数值,一定要转换为字符串:
TweenLite.to(mc, , {x:String(myVariable)}); TweenMax.pauseAll()
TweenMax.killAll();
转载修改于:http://blog.sina.com.cn/s/blog_8b7ca01301012d7n.html
as3 TweenMax TweenLite方法的更多相关文章
- as3 string split方法一些注意
split () 方法 AS3 function split(delimiter:*, limit:Number = 0x7fffffff):Array 如果指定 limit 参数,返回的数组中具有的 ...
- [ActionScript 3.0] AS3 时间格式化方法
/** * 格式化时间,格式 00:00:00 * @param total 总时间(毫秒) */ function getFormatTime(total:uint):String { if (to ...
- [ActionScript 3.0] AS3虚线绘制方法
import flash.geom.Point; import flash.display.MovieClip; import flash.display.Graphics; var mc:Movie ...
- TweenMax参数说明
TweenMax 建立在 TweenLite 和 TweenFilterLite 基础之上,因此,又揉合了这二者的功能,使得功能更加的齐备,但是如果说易用性,觉得还是 TweenLite 来得方便一些 ...
- TweenMax说明
TweenMax 采用了与它的兄弟相似的易于学习的语法结构.实事上,因为它扩展自它们,TweenMax 可以做任何 TweenLite 和/或者 TweenFilterLite 能做的事,还加上了更多 ...
- TweenMax参数用法中文介绍
TweenMax 建立在 TweenLite 和 TweenFilterLite 基础之上,因此,又揉合了这二者的功能,使得功能更加的齐备,但是如果说易用性,觉得还是 TweenLite 来得方便一些 ...
- 关于AIR新浪登录测试
/** *由于在应用申请中,我设置的域名属于新浪云,因此在本地测试的话肯定不能成功的,有个办法就是直接在新浪云那边授权成功后,将token的值直接使用post或者get方法传递过来,直接在本地 *lo ...
- 企业级时间轴插件Vue-timelinepick
简介 时间范围选择插件 取当前时间之前一段时间范围 按刻,小时,天分类 在线演示及下载 在线演示:https://yelingfeng.github.io/vue-timelinepick/ 本地下载 ...
- javaSE27天复习总结
JAVA学习总结 2 第一天 2 1:计算机概述(了解) 2 (1)计算机 2 (2)计算机硬件 2 (3)计算机软件 2 (4)软件开发(理解) 2 (5) ...
随机推荐
- oracle 、sql server 、mysql 复制表数据
我们知道在oracle 中复制表数据的方式是使用 create table table_name as select * from table_name 而在sql server 中是不能这么使用的 ...
- 注册表禁用和启用USB端口
USB端口禁用把下面代码另存为文件:USB_Disable.batcSCript \\AppServices\netlogon\USB_Disable.vbs--------------------- ...
- MySQL命令行--导入导出数据库
MySQL命令行导出数据库: 1,进入MySQL目录下的bin文件夹:cd MySQL中到bin文件夹的目录 如我输入的命令行:cd C:\Program Files\MySQL\MySQL Se ...
- 为什么有时候 php 没有写闭合标签结束符?
找了一些资料,大家对PHP闭合标签的总结如下: 好处:如果这个是一个被别人包含的程序,没有这个结束符,可以减少很多很多问题,比如说:header, setcookie, session_start这些 ...
- enjoy dollar vs cash dollar
當 enJoy 卡 客 戶 憑 enJoy 卡 於 enJoy 卡 「 特 約 商 戶 」 簽 賬 消 費 , 累 積 之 enJoy Dollars 及 Cash Dollars 可 在 同 一 交 ...
- drbd脑裂问题处理
http://blog.csdn.net/heianemo/article/details/8439813 split brain实际上是指在某种情况下,造成drbd的两个节点断开了连接,都以prim ...
- centos 使用mutt发送邮件带附件
1.安装mutt工具 yum install -y mutt 2.使用mutt发邮件并带附件echo "统计日志" | /usr/bin/mutt -s "统计日志&qu ...
- mySQL 教程 第4章 数据查询
mySQL运算符 这些运算符在SQL查询中用得到. 算数运算符 + 加 - 减 * 乘 / DIV 除 % MOD 取余数 比较运算符 = 等于 <> != 不等于 < <= ...
- bat文件:启动,休眠VBox虚拟机
1. start.Xp_Mysql.bat @echo cd D:\Program Files\VirtualBox\ D: .\VBoxManage startvm Xp_Mysql --type ...
- Winfrom 实现转圈等待
1.放弃进度条.动态进度图片等方式实现用户体验优化方式(主要是优化用户等待体验),建议使用方式? 答:对于From或者Control而言,其提供了Cursor属性设置即可. 例如: this.Curs ...