日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

greensock是个很不错的类库,故转载了一些关于其中类使用方法的文章。

發(fā)布時(shí)間:2024/8/1 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 greensock是个很不错的类库,故转载了一些关于其中类使用方法的文章。 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

一、greensock_plugins常用功能中文簡(jiǎn)介

http://bbs.9ria.com/thread-400375-1-1.html

原文鏈接:http://www.contactu.cn/article.asp?id=133

因?yàn)樵诰W(wǎng)上已經(jīng)發(fā)現(xiàn)一些未注明出處的轉(zhuǎn)載,所以我特地在天地會(huì)重發(fā)此文,轉(zhuǎn)載請(qǐng)注明本人原創(chuàng)即可。
--------------------------------------------------------------------------------------------------------
com.greensock.plugins是greensock庫(kù)中,與tweenLite/TweenMax等tween類(lèi)搭配使用的組合功能。雖然號(hào)稱(chēng)是插件,但是功能真的很強(qiáng)。有小而精練的功能,也有象運(yùn)動(dòng)模擬這樣的的大塊頭功能,這些都需要使用者慢慢的探索。這里只列出了自己常常使用的一些,讓大家能少讀幾行英文。
具體的使用方法、語(yǔ)法、如何包含庫(kù)等,可以閱讀原文示例: http://www.greensock.com/as/docs/tween/com/greensock/plugins/package-detail.html
這里還有一個(gè)更形象的的動(dòng)畫(huà)演示及代碼生成器: http://www.greensock.com/as/swf/PluginExplorer-v11.swf
另外,JS版本的plugins庫(kù)也已經(jīng)有了,文檔在這里: http://api.greensock.com/js/ ,相比AS來(lái)說(shuō),只能說(shuō)太弱太弱了。可以想見(jiàn),基于JS的動(dòng)畫(huà)開(kāi)發(fā),還在遠(yuǎn)遠(yuǎn)的追趕之中。

plugins名稱(chēng) 我的描述 原英文描述(英文好的請(qǐng)自行對(duì)照)
AutoAlphaPlugin 常用,當(dāng)緩動(dòng)alpha到零值時(shí),將visible自動(dòng)置為false不可見(jiàn)狀態(tài)。 Tweening "autoAlpha" is exactly the same as tweening an object's "alpha" except that it ensures that the object's "visible" property is true until autoAlpha reaches zero at which point it will toggle the "visible" property to false.
BevelFilterPlugin 不常用,浮雕邊濾鏡功能。 Tweens a BevelFilter.
BezierPlugin 不常用,但功能強(qiáng)大,可以擬合貝塞爾曲線(xiàn)路徑。 Bezier tweening allows you to tween in a non-linear way.
BezierThroughPlugin 不常用,貝塞爾曲線(xiàn)路徑相關(guān)。 Identical to bezier except that instead of defining bezier control point values, you define points through which the bezier values should move.
BlurFilterPlugin 常用,模糊效果全靠它了。
Tweens a BlurFilter.
CacheAsBitmapPlugin 沒(méi)用過(guò)。 Forces the cacheAsBitmap property of a DisplayObject to be a certain value (true or false) during the tween and then sets it back to whatever it was before the tween was rendered for the first time.
CirclePath2DPlugin ? Tweens an object along a CirclePath2D motion path in any direction (clockwise, counter-clockwise, or shortest).
ColorMatrixFilterPlugin ? ColorMatrixFilter tweening offers an easy way to tween a DisplayObject's saturation, hue, contrast, brightness, and colorization.
ColorTransformPlugin 很常用,尤其在做一些變色效果時(shí),比如鼠標(biāo)點(diǎn)上去變色、變高亮等--鼠標(biāo)移開(kāi)后又恢復(fù)原狀等。
Ever wanted to tween ColorTransform properties of a DisplayObject to do advanced effects like overexposing, altering the brightness or setting the percent/amount of tint? or maybe tween individual ColorTransform properties like redMultiplier, redOffset, blueMultiplier, blueOffset, etc.
DropShadowFilterPlugin 常用,陰影濾鏡,跟發(fā)光略有區(qū)別。 Tweens a DropShadowFilter.
DynamicPropsPlugin ? If you'd like to tween something to a destination value that may change at any time, DynamicPropsPlugin allows you to simply associate a function with a property so that every time the tween is rendered, it calls that function to get the new destination value for the associated property.
EndArrayPlugin ? Tweens numbers in an Array.
EndVectorPlugin ? Tweens numbers in an Vector.<Number>.
FrameBackwardPlugin 小功能,向前N幀。 Tweens a MovieClip backward to a particular frame number, wrapping it if/when it reaches the beginning of the timeline.
FrameForwardPlugin 小功能,向后N幀。 Tweens a MovieClip forward to a particular frame number, wrapping it if/when it reaches the end of the timeline.
FrameLabelPlugin 居家必備之常用功能,緩動(dòng)到指定的幀標(biāo)簽。 Tweens a MovieClip to a particular frame label.
FramePlugin 緩動(dòng)到指定幀(用幀數(shù)字表示的)。 Tweens a MovieClip to a particular frame number.
GlowFilterPlugin 居家必備功能,發(fā)光濾鏡值的緩動(dòng)控制。 Tweens a GlowFilter.
HexColorsPlugin ? Although hex colors are technically numbers, if you try to tween them conventionally, you'll notice that they don't tween smoothly.
LiquidPositionPlugin 很少用的功能,要跟LiquidStage相結(jié)合的一個(gè)功能。
LiquidStage本來(lái)就是GS會(huì)員才有的功能,一般人都不會(huì)用。LiquidStage介紹參見(jiàn)拙作:http://www.contactu.cn/article.asp?id=60
If you're using LiquidStage and you'd like to tween a DisplayObject to coordinates that are relative to a particular PinPoint (like the CENTER) whose position may change at any time,LiquidPositionPlugin makes it easy by dynamically updating the destination values accordingly.
MotionBlurPlugin 高級(jí)貨-運(yùn)動(dòng)模糊插件,可以在運(yùn)動(dòng)時(shí)按運(yùn)行方向產(chǎn)生模糊效果,做一些求逼真的效果,非常有用!但這是個(gè)會(huì)員才擁有的功能,好吧,反正我是會(huì)員。 MotionBlurPlugin provides an easy way to apply a directional blur to a DisplayObject based on its velocity and angle of movement in 2D (x/y).
Physics2DPlugin 高級(jí)貨,會(huì)員功能,能產(chǎn)生逼真的運(yùn)動(dòng)學(xué)效果,看示意圖就知道了。 Provides simple physics functionality for tweening a DisplayObject's x and y coordinates based on a combination of velocity, angle, gravity, acceleration, accelerationAngle, and/or friction.
PhysicsPropsPlugin ? Sometimes you want to tween a property (or several) but you don't have a specific end value in mind - instead, you'd rather describe the movement in terms of physics concepts, like velocity, acceleration, and/or friction.
QuaternionsPlugin ? Performs SLERP interpolation between 2 Quaternions.
RemoveTintPlugin 常用,移除加色效果,加色效果就是下面的TintPlugin Removes the tint of a DisplayObject over time.
RoundPropsPlugin ? If you'd like the inbetween values in a tween to always get rounded to the nearest integer, use the roundProps special property.
ScalePlugin 小功能,讓scaleX和scaleY同時(shí)變化。 ScalePlugin combines scaleX and scaleY into one "scale" property.
ScrollRectPlugin 小功能,讓方塊形狀進(jìn)行x/y/寬/高的同時(shí)變化。 Tweens the scrollRect property of a DisplayObject.
SetActualSizePlugin 沒(méi)看太懂,似乎是讓一些組件類(lèi)恢復(fù)到原來(lái)的形狀,不常用。 Some components require resizing with setActualSize() instead of standard tweens of width/height in order to scale properly.
SetSizePlugin 小功能。讓寬和高同時(shí)變化。 Some components require resizing with setSize() instead of standard tweens of width/height in order to scale properly.
ShortRotationPlugin 不太常用但很有用的功能--沿短邊旋轉(zhuǎn):當(dāng)進(jìn)行旋轉(zhuǎn)時(shí),會(huì)如果大于180度,會(huì)沿較小角度的那邊旋轉(zhuǎn)過(guò)去(反向)。 To tween any rotation property of the target object in the shortest direction, use "shortRotation" For example, if myObject.rotation is currently 170 degrees and you want to tween it to -170 degrees, a normal rotation tween would travel a total of 340 degrees in the counter-clockwise direction, but if you use shortRotation, it would travel 20 degrees in the clockwise direction instead.
SoundTransformPlugin 跟聲音相關(guān)的,可以緩動(dòng)一切跟聲音相關(guān)的屬性,音量、聲道平衡、左轉(zhuǎn)右等。 Tweens properties of an object's soundTransform property (like the volume, pan, leftToRight, etc.
StageQualityPlugin 對(duì)畫(huà)面質(zhì)量的一個(gè)緩動(dòng),沒(méi)啥大用。 Sets the stage's quality to a particular value during a tween and another value after the tween which can be useful for improving rendering performance in the Flash Player while things are animating.
ThrowPropsPlugin ? ThrowPropsPlugin allows you to simply define an initial velocity for a property (or multiple properties) as well as optional maximum and/or minimum end values and then it will calculate the appropriate landing position and plot a smooth course based on the easing equation you define (Quad.easeOut by default, as set in TweenLite).
TintPlugin 非常常用,向目標(biāo)色緩動(dòng)變色。比ColorTransformPlugin要簡(jiǎn)單,適用于簡(jiǎn)單的變色功能。 To change a DisplayObject's tint/color, set this to the hex value of the tint you'd like to end up at (or begin at if you're using TweenMax.from()).
TransformAroundCenterPlugin 常用!好用!以MC中心點(diǎn)進(jìn)行旋轉(zhuǎn)。 Normally, all transformations (scale, rotation, and position) are based on the DisplayObject's registration point (most often its upper left corner), but TransformAroundCenter allows you to make the 2D transformations occur around the DisplayObject's center.
TransformAroundPointPlugin 牛!用你指定的點(diǎn)進(jìn)行旋轉(zhuǎn)。 Normally, all transformations (scale, rotation, and position) are based on the DisplayObject's registration point (most often its upper left corner), but TransformAroundPoint allows you to define ANY point around which 2D transformations will occur during the tween.
TransformMatrixPlugin ? TransformMatrixPlugin allows you to tween a DisplayObject's transform.matrix values directly (a, b, c, d, tx, and ty) or use common properties like x, y, scaleX, scaleY, skewX, skewY, rotation and even shortRotation.
TweenPlugin 這個(gè)不能直接用,是所有插件類(lèi)的基類(lèi)。 TweenPlugin is the base class for all TweenLite/TweenMax plugins.
VisiblePlugin 小功能,在任何緩動(dòng)過(guò)程的終點(diǎn),讓MC不可見(jiàn)。 Toggles the visibility at the end of a tween.
VolumePlugin 跟音量相關(guān)的緩動(dòng),媽呀,總算寫(xiě)完了。 Tweens the volume of an object with a soundTransform property (MovieClip/SoundChannel/NetStream, etc.).


二、TweenMax使用方法記錄

轉(zhuǎn)自:http://bbs.9ria.com/thread-150136-1-1.html


greensock緩動(dòng)類(lèi)包之TweenMax
1~了解TweenMax類(lèi)
? ? TweenMax建立在TweenLite核心類(lèi)及TweenFilterLite基礎(chǔ)之上,新增功能:
? ? 1) 進(jìn)行貝塞爾緩動(dòng)
? ? 2)連續(xù)的緩動(dòng)(序列化的緩動(dòng))
? ? 3)對(duì)對(duì)象數(shù)組中的對(duì)象進(jìn)行同意的緩動(dòng)使用allTo()或allFrom();
? ? 4)緩動(dòng)中的暫停/繼續(xù)功能,使用pause()和resume()方法,或“paused”屬性
? ? 5)跳轉(zhuǎn)至緩動(dòng)的任何時(shí)段,使用“progress”屬性。輸入一個(gè)0~1之間的數(shù)值
? ? 6)對(duì)16進(jìn)制的顏色進(jìn)行緩動(dòng),使用hexColors屬性
? ? 7)獲取緩動(dòng)效果的實(shí)例數(shù)組,該數(shù)組中包括了加在一個(gè)指定目標(biāo)對(duì)象上的所有的緩動(dòng)效果的實(shí)例,TweenMax.getTweensOf(mc);如果該mc應(yīng)用了多個(gè)緩動(dòng)效果,則返回一個(gè)數(shù)組,數(shù)組中是不同的緩動(dòng)效果的實(shí)例
? ? 8)獲取TweenMax、TweenLite和TweenFilterLite的實(shí)例數(shù)組,使用靜態(tài)函數(shù)getAllTweens();
? ? 9)種植所有的緩動(dòng)
? ? 10)暫停/繼續(xù)全部的緩動(dòng)
2~常用方法
? ? ?1)public function TweenMax(target:Object, duration:Number, vars:Object)
? ? 描述:構(gòu)造方法
? ? ?target:目標(biāo)對(duì)象;duration:持續(xù)的時(shí)間(單位:秒);vars:包含想要緩動(dòng)的的屬性值
? ???vars:緩動(dòng)的常用屬性包括{
? ? alpha:Number:目標(biāo)對(duì)象在緩動(dòng)結(jié)束時(shí)的alpha
? ? delay:Number:延遲緩動(dòng)
? ? ease:Function:緩動(dòng)函數(shù)
? ? easeParames:Array:緩動(dòng)函數(shù)中的參數(shù)
?? ? autoAlpha:Number:用來(lái)代替alpha屬性,可獲得一些附加小伙,實(shí)現(xiàn)透明度緩動(dòng)效果
?? ? volume:Number:改變MovieClip或者SoundChannel的音量,將緩動(dòng)結(jié)束時(shí)的音量值調(diào)整為指定的值
?? ? tint:Number:改變可顯示對(duì)象的色調(diào)/顏色
?? ? frame:Number:將MovieClip緩動(dòng)到指定的幀頻
?? ? bezier:Array:Bezier緩動(dòng),允許你以非線(xiàn)醒的方式進(jìn)行緩動(dòng)
? ? bezierThrough:Array:貝賽爾曲線(xiàn)要經(jīng)過(guò)的位置點(diǎn)
?? ? orientToBezier:Array:使MovieClip自動(dòng)調(diào)整自身的方向,使之符合貝塞爾路徑[x,y,rotation,ang](rotation:旋轉(zhuǎn)屬性,ang:旋轉(zhuǎn)的度數(shù))
? ? hexColors:Object:緩動(dòng)指定對(duì)象中相應(yīng)顏色屬性的值(TweenMax.to(my_obj,{hexColors:{mycolor:0Xff0000}}))
? ? onStart:Function:在緩動(dòng)開(kāi)始時(shí)想要執(zhí)行的某個(gè)函數(shù)
?? ? onStartParams:Array:緩動(dòng)開(kāi)始時(shí)要執(zhí)行函數(shù)的參數(shù)
?? ? onUpdate:Function:緩動(dòng)過(guò)程中,每次更新屬性值時(shí),要執(zhí)行的函數(shù)
? ? onUpdateParams:Array:同上。。
? ? onComplete:Function:緩動(dòng)結(jié)束時(shí)要執(zhí)行的函數(shù)
?? ? onCompleteParams:Array:同上。。?? ?
?? ? renderOnStart:Boolean:阻止緩動(dòng)的渲染效果直到緩動(dòng)真正開(kāi)始
? ? overwrite:Boolean:緩動(dòng)效果是否可以被覆蓋
? ? blurFilter:Object:應(yīng)用模糊濾鏡,需要傳遞一個(gè)具有下列屬性的對(duì)象作為參數(shù):blurX(橫向的模糊度),blurY(縱向的模糊度),quality(品質(zhì),默認(rèn)值為2)
? ? glowFilter:Object:應(yīng)用發(fā)光濾鏡,需要傳遞一個(gè)帶有以下屬性的對(duì)象:alpha,blurX,blurY,color,strength(強(qiáng)度),quality,inner(內(nèi)側(cè)發(fā)?? ? ?? ? ?? ? 光),knockout(挖空)
?? ? colorMatrixFilter:Object:應(yīng)用顏色矩陣濾鏡,需要傳遞一個(gè)帶有以下屬性的對(duì)象:colorize(色調(diào)),amount(總量),contrast(對(duì)比度),brightness(亮度),saturation(飽和度),hue(色相),threshold(閥值),relative(相關(guān)性),matrix(顏色矩陣)
?? ? dropShadowFilter:Object:應(yīng)用陰影濾鏡,需要傳遞一個(gè)帶有以下屬性的對(duì)象:alpha,angle(角度),blurX,blurY,color,distance(距離),strength,quality
?? ? bevelFilter:Object:應(yīng)用斜角濾鏡,需要傳遞一個(gè)帶有以下屬性的對(duì)象:angle,blurX,blurY,distance,hightlightAlpha(高亮區(qū)的透明度),highlightColor(高亮區(qū)的顏色),shadowAlpha(陰影區(qū)的透明度),shadowColor(陰影區(qū)的顏色),strength(強(qiáng)度),quality

?? ? progress:Number:緩動(dòng)進(jìn)程0~1
?? ? paused:Boolean:是否停止緩動(dòng)

2)allTo(targets:Array, duration:Number, vars:Object):Array
返回的是一個(gè)數(shù)組保存了創(chuàng)建的所有TweenMax Object。
3)?allFrom(targets:Array, duration:Number, vars:Object):Array
跟allTo一樣,只是定義的是運(yùn)動(dòng)對(duì)象的初始狀態(tài),運(yùn)動(dòng)到當(dāng)前狀態(tài)。
4)?complete(skipRender:Boolean = false, suppressEvents:Boolean = false):void
? ?強(qiáng)制TweenMax到最后結(jié)束部分。如果第一個(gè)參數(shù)設(shè)為true,則不會(huì)渲染,TweenMax將停在調(diào)用那一刻。如果第二個(gè)參數(shù)設(shè)為true則不會(huì)觸發(fā)onCompelte,onUpdate等事件。
5)?delayedCall(delay:Number, onComplete:Function, onCompleteParams:Array = null, useFrames:Boolean = false):TweenMax?
? ??延遲執(zhí)行函數(shù)

6)getTweensOf(target:Object):Array
?返回運(yùn)動(dòng)物體正在運(yùn)行的的TweenMax Object
7)isTweening(target:Object):Boolean
?判斷是否正在緩動(dòng)
8)?updateTo(vars:Object, resetDuration:Boolean = false):void
?可以在運(yùn)行中新增或改變?cè)械膶傩宰兓怠5诙€(gè)參數(shù)設(shè)為false時(shí)將不重播緩動(dòng),而繼續(xù)緩動(dòng)到新的值;設(shè)為true將中斷并重播緩動(dòng)。

三、Tweenlite的用法

轉(zhuǎn)自:http://blog.csdn.net/jinglikeblue/article/details/9134433

TweenLite 是一個(gè)緩動(dòng)的類(lèi)包,功能強(qiáng)大,并且易于使用,為了更多的(E文欠佳的、初學(xué)的)朋友了解它,使用它,特此翻譯了一下TweenLite 類(lèi)文檔中的說(shuō)明文件,主要是對(duì)參數(shù)的說(shuō)明,希望對(duì)大家有用。
描述:
緩動(dòng)。 我們都在做。我們很多人都知道除了 Adobe’s Tween 類(lèi)之外,還有很多更好的動(dòng)畫(huà)引擎,(比如 Tweener). 每種引擎都有它們各自的優(yōu)缺點(diǎn)。
最近幾年,為了得到一個(gè)更緊湊的,跑得更快,效率更高的引擎,我創(chuàng)建了 TweenLite (我無(wú)法接受其它的一些引擎帶來(lái)的文件尺寸上的負(fù)擔(dān)).它很快就融入到我的所有工作中。我告訴其它人,讓大家能夠從中獲益,最終,我將它發(fā)布了出來(lái)。在過(guò)去的幾年中,TweenLite越來(lái)越受歡迎,超乎了我的想像.
基于此,我又添加了一些新的功能,并且盡量保持這個(gè)文件的尺寸,讓它小于3K。 TweenFilterLite 擴(kuò)充了 TweenLite 并且加入了濾鏡緩動(dòng),包含了 ColorMatrixFilter 的一些效果,比如飽和、對(duì)比、增亮、色調(diào),甚至是著色,但文件的尺寸始終沒(méi)有超過(guò)3K。與 TweenLite 的做法相似,提供有AS2版和AS3版的類(lèi)包下載。
TweenMax 比 TweenFilterLite 增加了更多的特性,包含 bezier 緩動(dòng),暫停/恢復(fù),順序執(zhí)行等等。(見(jiàn) www.TweenMax.com)
我猜你會(huì)想“如果這個(gè)是‘輕量級(jí)的’,那么它一定會(huì)丟掉很多特性,讓我用的時(shí)候會(huì)有點(diǎn)擔(dān)心”。這種想法是對(duì)的,在這里缺少一些其它緩動(dòng)引擎所包含的特效,但是我可以肯定的說(shuō),在過(guò)去幾年我的工程(很多獲獎(jiǎng)的 flash 程序以及500強(qiáng)企業(yè)的項(xiàng)目中)中,我?guī)缀跻恢倍荚谟盟?#xff0c;而它從沒(méi)有讓我失望過(guò)。
我還真沒(méi)發(fā)現(xiàn)過(guò)我還需要其它的功能。你可以對(duì)任何的屬性(包括 DisplayObject 對(duì)象的音量和顏色)使用緩動(dòng)函數(shù),內(nèi)置的延遲時(shí)間,回調(diào)函數(shù),以及傳遞參數(shù)給這些回調(diào)函數(shù),甚至根據(jù)數(shù)組進(jìn)行緩動(dòng),統(tǒng)統(tǒng)只在一行代碼中完成。如果你需要更多的特效,你可以裝上TweenFilterLite 或者 TweenMax來(lái)用用。
我也從來(lái)沒(méi)有發(fā)現(xiàn)比這個(gè)更快的引擎。不同引擎執(zhí)行效率的比較,請(qǐng)?jiān)L問(wèn) http://blog.greensock.com/tweeing-speed-test/.

TweenLite參數(shù)說(shuō)明:
1) $target : Object – 作為目標(biāo)的對(duì)象, MovieClip或者其它對(duì)象
2) $duration : Number – 動(dòng)畫(huà)的時(shí)間長(zhǎng)度(單位:秒)
3) $vars : Object – 對(duì)象,通過(guò)屬性值,來(lái)存貯各種屬性參數(shù)用于緩動(dòng)。(如果你使用 TweenLite.from() 方法,這里的參數(shù)表示緩動(dòng)的初始值)
該對(duì)象所具有的屬性:
alpha: alpha 目標(biāo)對(duì)象應(yīng)該完成 (或開(kāi)始,當(dāng)使用 TweenLite.from()時(shí))的透明度級(jí)別.如果 target.alpha 是1,當(dāng)緩動(dòng)被執(zhí)行的時(shí)候,你指定參數(shù)為 0.5,它將把透明度從 1 緩動(dòng)到 0.5.
x: 改變 MovieClip的 x 位置,把這個(gè)值設(shè)置成你希望的 MovieClip 的結(jié)束位置(如果你使用的是 TweenLite.from()這個(gè)值表示開(kāi)始位置).
           ( y scaleX scaleY rotation 等屬性不再重復(fù)說(shuō)明)
特別的屬性 (**可選的**):
delay : Number – 延遲緩動(dòng) (以秒為單位).
ease : Function – 緩動(dòng)函數(shù). 例如,fl.motion.easing.Elastic.easeOut 函數(shù)。默認(rèn)的是 Regular.easeOut函數(shù)。
easeParams : Array – 用來(lái)存貯緩動(dòng)公式所需要的額外數(shù)據(jù). 當(dāng)使用 Elastic 公式并且希望控制一些額外的參數(shù),比如放大系數(shù)和緩動(dòng)時(shí)間。大多數(shù)的緩動(dòng)公式是不需要參數(shù)的,因此,你不需要給其它的緩動(dòng)公式傳遞參數(shù)。
autoAlpha : Number – 用它來(lái)代替 alpha 屬性,可以獲得一些副加的效果,比如當(dāng) alpha 值緩動(dòng)到 0時(shí),自動(dòng)將 visible 屬性改為 false。當(dāng)緩動(dòng)開(kāi)始前,autoAlpha 大于 0時(shí),它將會(huì)把 visible 屬性變成 true 。
visible : Boolean – 在緩動(dòng)結(jié)束時(shí),想要指定 DisplayObject 的 visible 屬性,請(qǐng)使用這個(gè)參數(shù)。
volume : Number – 對(duì) soundTransform (MovieClip/SoundChannel/NetStream 等)對(duì)象中的volume屬性(音量大小)進(jìn)行緩動(dòng)
tint : Number – 改變 DisplayObject 的顏色,設(shè)置一個(gè)16進(jìn)制顏色值之后,當(dāng)緩動(dòng)結(jié)束時(shí),目標(biāo)對(duì)象將被變成這個(gè)顏色,(如果使用的是TweenLite.from(),這個(gè)值將表示目標(biāo)對(duì)象開(kāi)始緩動(dòng)時(shí)的顏色)。舉個(gè)例子,顏色值可以設(shè)定為: 0xFF0000。
removeTint : Boolean – 要移除 DisplayObject 顏色,將這個(gè)參數(shù)設(shè)成 true 。
frame : Number – 將 MovieClip 緩動(dòng)到指幀頻。
onStart : Function – 在緩動(dòng)開(kāi)始時(shí)想要執(zhí)行某個(gè)函數(shù),就將函數(shù)的引用(通常是函數(shù)名)放到這里。如果緩動(dòng)是帶延遲的,那么在緩動(dòng)開(kāi)始前該函數(shù)不會(huì)被執(zhí)行。
onStartParams : Array – 為緩動(dòng)開(kāi)始時(shí)要執(zhí)行的函數(shù)傳遞參數(shù)。(可選的)
onUpdate : Function – 緩動(dòng)過(guò)程中,每次更新時(shí)調(diào)用這里指定的函數(shù)(緩動(dòng)開(kāi)始后,每一幀被觸發(fā)一次),
onUpdateParams : Array – 給 onUpdate 參數(shù)指定的函數(shù)傳遞參數(shù) (可選的)
onComplete : Function – 緩動(dòng)結(jié)束時(shí)執(zhí)行的函數(shù)。
onCompleteParams : Array – 給 onComplete 參數(shù)指定的函數(shù)傳遞參數(shù) (可選的)
persist : Boolean – 值為 true 時(shí),TweenLite 實(shí)例將不會(huì)自動(dòng)被系統(tǒng)的垃圾收集器給收走。但是當(dāng)新的緩動(dòng)出現(xiàn)時(shí),它還是會(huì)被重寫(xiě)(overwritten)默認(rèn)值為 false.
renderOnStart : Boolean – 如果你使用帶有延遲緩動(dòng)的 TweenFilterLite.from() ,并且阻止緩動(dòng)的渲染(rendering )效果,直到緩動(dòng)真正開(kāi)始,將這個(gè)值設(shè)為 true.默認(rèn)情況下該值為 false ,這會(huì)讓渲染效果立即被執(zhí)行,甚至是在延遲的時(shí)間還沒(méi)到之前。
overwrite : int – 當(dāng)前的緩動(dòng)被創(chuàng)建以后,通過(guò)這個(gè)參數(shù)可以限制作用于同一個(gè)對(duì)象的其它緩動(dòng),可選的參數(shù)值有:
- 0 (沒(méi)有): 沒(méi)有緩動(dòng)被重寫(xiě)。這種模式下,運(yùn)行速度是最快的,但是需要注意避免創(chuàng)建一些控制相同屬性的緩動(dòng),否則這些緩動(dòng)效果間將出現(xiàn)沖突。
- 1 (全部): (這是默認(rèn)值,除非 OverwriteManager.init() 被調(diào)用過(guò))對(duì)于同一對(duì)象的所有緩動(dòng)在創(chuàng)建時(shí)將會(huì)被完全的覆蓋掉。
TweenLite.to(mc, 1, {x:100, y:200});
TweenLite.to(mc, 1, {x:300, delay:2}); //后創(chuàng)建的緩動(dòng)將會(huì)覆蓋掉先前創(chuàng)建的緩動(dòng),(可以起到這樣的作用:緩動(dòng)進(jìn)行到一半時(shí)被中斷,執(zhí)行新的緩動(dòng) 譯者注)
- 2 (自動(dòng)): (當(dāng) OverwriteManager.init() 被執(zhí)行后,會(huì)根據(jù)具體的屬性值進(jìn)行選擇)只覆蓋對(duì)同一屬性的緩動(dòng)。
TweenLite.to(mc, 1, {x:100, y:200});
TweenLite.to(mc, 1, {x:300}); //only “x” 屬性的緩動(dòng)將被覆蓋
- 3 (同時(shí)發(fā)生): 緩動(dòng)開(kāi)始時(shí),覆蓋全部的緩動(dòng)。
TweenLite.to(mc, 1, {x:100, y:200});
TweenLite.to(mc, 1, {x:300, delay:2}); //不會(huì)覆蓋先前的緩動(dòng),因?yàn)槊慷€(gè)緩動(dòng)開(kāi)始時(shí),第一個(gè)緩動(dòng)已經(jīng)結(jié)束了。

舉例:
將實(shí)例名為 “clip_mc” 的 MovieClip 透明度降到 50% (0.5) ,并將它 x 軸位置移動(dòng)到 120 ,將音量將到 0,緩動(dòng)總共用時(shí) 1.5 秒,代碼如下:
import gs.TweenLite;
TweenLite.to(clip_mc, 1.5, {alpha:0.5, x:120, volume:0});

如果希望使用更高級(jí)的緩動(dòng)函數(shù)在 5 內(nèi),將 alpha 變到 0.5,將 x 移動(dòng) 到 120 ,使用 “easeOutBack” 彈性函數(shù),緩動(dòng)整體延遲 2 秒發(fā)生,并且在緩動(dòng)結(jié)束時(shí),執(zhí)行 “onFinishTween” 函數(shù),并且為這個(gè)函數(shù)傳遞幾個(gè)參數(shù),(一個(gè)數(shù)值 5 以及對(duì) clip_mc 的引用),代碼如下:
import gs.TweenLite;
import fl.motion.easing.Back;
TweenLite.to(clip_mc, 5, {alpha:0.5, x:120, ease:Back.easeOut, delay:2, onComplete: onFinishTween, onCompleteParams:[5, clip_mc]});
function onFinishTween(argument1:Number, argument2:MovieClip):void {
trace(“The tween has finished! argument1 = ” + argument1 + “, and argument2 = ” + argument2);
}

如果你的舞臺(tái)上的 MovieClip 已經(jīng)停在了它的結(jié)束位置,你只想讓它花上5秒種回到這個(gè)位置,(只需要改變 y 屬性,比當(dāng)前位置高 100 像素的位置,讓它從那里下落), 代碼如下(這次使用的是 TweenLite.from 譯者注):
import gs.TweenLite;
import fl.motion.easing.Elastic;
TweenLite.from(clip_mc, 5, {y:”-100″, ease:Elastic.easeOut});

說(shuō)明:
- TweenLite類(lèi)會(huì)讓你的 Flash 文件增加 3kb大小。
- 給參數(shù)值加上引號(hào),表示對(duì)指定的屬性進(jìn)行相應(yīng)操作。比如,使用 TweenLite.to(mc, 2, {x:”-20″}); 它將 mc.x 向左移動(dòng) 20 像素,與此相同效果的代碼是:TweenLite.to(mc, 2, {x:mc.x – 20});
- 你可以用別的緩動(dòng)函數(shù)替換 TweenLite 默認(rèn)的緩動(dòng)函數(shù): Regular.easeOut.
- 必須使用 Flash Player 9 或之后版本的播放器 (ActionScript 3.0)
- 可以對(duì)任何 MovieClip 使用 “volume” 緩動(dòng),就比如:TweenLite.to(myClip_mc, 1.5, {volume:0});
- 可以將 MovieClip 設(shè)定成某種顏色,使用 “tint” 參數(shù),比如: TweenLite.to(myClip_mc, 1.5, {tint:0xFF0000});
- 想要對(duì)數(shù)組內(nèi)容進(jìn)行緩動(dòng),將數(shù)值放到一個(gè)叫 endArray 的數(shù)組中即可,例如:
var myArray:Array = [1,2,3,4];
TweenLite.to(myArray, 1.5, {endArray:[10,20,30,40]});
- 可以在任何時(shí)候終止緩動(dòng),使用 TweenLite.killTweensOf(myClip_mc); 函數(shù)。如果想強(qiáng)制終止緩動(dòng),可以傳遞一個(gè) true 做為第二個(gè)參數(shù),比如
TweenLite.killTweensOf(myClip_mc, true);
- 取掉延遲回調(diào)函數(shù),用 TweenLite.killDelayedCallsTo(myFunction_func);這項(xiàng)功能可以用來(lái)控制回調(diào)函數(shù)的優(yōu)先級(jí)。
- 使用 TweenLite.from() 方法,可以使用對(duì)象從別的位置回到當(dāng)前的位置。例如,你可以將對(duì)象在舞臺(tái)上擺放整齊(緩動(dòng)結(jié)束時(shí)的位置),然后利用
緩動(dòng),讓它們跑到那個(gè)位置上去,你可以將緩動(dòng)的初始位置值 x 或 y 或 alpha (或者其它你需要的屬性)當(dāng)做參數(shù)傳遞給這個(gè)方法函數(shù)。

TweenLite 下載鏈接:
http://www.greensock.com/ActionS … S3/TweenLiteAS3.zip
下載下來(lái)的類(lèi)包中,有一個(gè) TweenLiteAS3_Sample_1.swf ,初學(xué)者可以用它來(lái)觀察各種緩動(dòng)的效果,并且直接得到相關(guān)的執(zhí)行代碼。算是一個(gè)可視化設(shè)計(jì)的工具,不要錯(cuò)過(guò)。
下載到類(lèi)包以后,解壓縮到一個(gè)目錄比如:d:\AS3Class ,在flash9 的首選參數(shù)->ActionScript->ActionScript3.0設(shè)置中添加類(lèi)目錄,d:\AS3Class\TweenLiteAS3 即可正確引用到相關(guān)的類(lèi)。

應(yīng)用舉例:
import gs.TweenLite;
import gs.easing.*;

stage.addEventListener(MouseEvent.CLICK, onCK);
function onCK(evt) {
TweenLite.to(mc, 0.5, {x:mouseX, y:mouseY, rotation:360});
}
在舞臺(tái)上點(diǎn)擊,會(huì)讓mc 元件旋轉(zhuǎn)并跑動(dòng)到鼠標(biāo)位置。



總結(jié)

以上是生活随笔為你收集整理的greensock是个很不错的类库,故转载了一些关于其中类使用方法的文章。的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。