日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

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

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

一、greensock_plugins常用功能中文簡介

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

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

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

plugins名稱 我的描述 原英文描述(英文好的請自行對照)
AutoAlphaPlugin 常用,當(dāng)緩動alpha到零值時,將visible自動置為false不可見狀態(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 不常用,但功能強大,可以擬合貝塞爾曲線路徑。 Bezier tweening allows you to tween in a non-linear way.
BezierThroughPlugin 不常用,貝塞爾曲線路徑相關(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 沒用過。 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 很常用,尤其在做一些變色效果時,比如鼠標點上去變色、變高亮等--鼠標移開后又恢復(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 居家必備之常用功能,緩動到指定的幀標簽。 Tweens a MovieClip to a particular frame label.
FramePlugin 緩動到指定幀(用幀數(shù)字表示的)。 Tweens a MovieClip to a particular frame number.
GlowFilterPlugin 居家必備功能,發(fā)光濾鏡值的緩動控制。 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é)合的一個功能。
LiquidStage本來就是GS會員才有的功能,一般人都不會用。LiquidStage介紹參見拙作: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 高級貨-運動模糊插件,可以在運動時按運行方向產(chǎn)生模糊效果,做一些求逼真的效果,非常有用!但這是個會員才擁有的功能,好吧,反正我是會員。 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 高級貨,會員功能,能產(chǎn)生逼真的運動學(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同時變化。 ScalePlugin combines scaleX and scaleY into one "scale" property.
ScrollRectPlugin 小功能,讓方塊形狀進行x/y/寬/高的同時變化。 Tweens the scrollRect property of a DisplayObject.
SetActualSizePlugin 沒看太懂,似乎是讓一些組件類恢復(fù)到原來的形狀,不常用。 Some components require resizing with setActualSize() instead of standard tweens of width/height in order to scale properly.
SetSizePlugin 小功能。讓寬和高同時變化。 Some components require resizing with setSize() instead of standard tweens of width/height in order to scale properly.
ShortRotationPlugin 不太常用但很有用的功能--沿短邊旋轉(zhuǎn):當(dāng)進行旋轉(zhuǎn)時,會如果大于180度,會沿較小角度的那邊旋轉(zhuǎn)過去(反向)。 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)的,可以緩動一切跟聲音相關(guān)的屬性,音量、聲道平衡、左轉(zhuǎn)右等。 Tweens properties of an object's soundTransform property (like the volume, pan, leftToRight, etc.
StageQualityPlugin 對畫面質(zhì)量的一個緩動,沒啥大用。 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 非常常用,向目標色緩動變色。比ColorTransformPlugin要簡單,適用于簡單的變色功能。 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中心點進行旋轉(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 牛!用你指定的點進行旋轉(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 這個不能直接用,是所有插件類的基類。 TweenPlugin is the base class for all TweenLite/TweenMax plugins.
VisiblePlugin 小功能,在任何緩動過程的終點,讓MC不可見。 Toggles the visibility at the end of a tween.
VolumePlugin 跟音量相關(guān)的緩動,媽呀,總算寫完了。 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緩動類包之TweenMax
1~了解TweenMax類
? ? TweenMax建立在TweenLite核心類及TweenFilterLite基礎(chǔ)之上,新增功能:
? ? 1) 進行貝塞爾緩動
? ? 2)連續(xù)的緩動(序列化的緩動)
? ? 3)對對象數(shù)組中的對象進行同意的緩動使用allTo()或allFrom();
? ? 4)緩動中的暫停/繼續(xù)功能,使用pause()和resume()方法,或“paused”屬性
? ? 5)跳轉(zhuǎn)至緩動的任何時段,使用“progress”屬性。輸入一個0~1之間的數(shù)值
? ? 6)對16進制的顏色進行緩動,使用hexColors屬性
? ? 7)獲取緩動效果的實例數(shù)組,該數(shù)組中包括了加在一個指定目標對象上的所有的緩動效果的實例,TweenMax.getTweensOf(mc);如果該mc應(yīng)用了多個緩動效果,則返回一個數(shù)組,數(shù)組中是不同的緩動效果的實例
? ? 8)獲取TweenMax、TweenLite和TweenFilterLite的實例數(shù)組,使用靜態(tài)函數(shù)getAllTweens();
? ? 9)種植所有的緩動
? ? 10)暫停/繼續(xù)全部的緩動
2~常用方法
? ? ?1)public function TweenMax(target:Object, duration:Number, vars:Object)
? ? 描述:構(gòu)造方法
? ? ?target:目標對象;duration:持續(xù)的時間(單位:秒);vars:包含想要緩動的的屬性值
? ???vars:緩動的常用屬性包括{
? ? alpha:Number:目標對象在緩動結(jié)束時的alpha
? ? delay:Number:延遲緩動
? ? ease:Function:緩動函數(shù)
? ? easeParames:Array:緩動函數(shù)中的參數(shù)
?? ? autoAlpha:Number:用來代替alpha屬性,可獲得一些附加小伙,實現(xiàn)透明度緩動效果
?? ? volume:Number:改變MovieClip或者SoundChannel的音量,將緩動結(jié)束時的音量值調(diào)整為指定的值
?? ? tint:Number:改變可顯示對象的色調(diào)/顏色
?? ? frame:Number:將MovieClip緩動到指定的幀頻
?? ? bezier:Array:Bezier緩動,允許你以非線醒的方式進行緩動
? ? bezierThrough:Array:貝賽爾曲線要經(jīng)過的位置點
?? ? orientToBezier:Array:使MovieClip自動調(diào)整自身的方向,使之符合貝塞爾路徑[x,y,rotation,ang](rotation:旋轉(zhuǎn)屬性,ang:旋轉(zhuǎn)的度數(shù))
? ? hexColors:Object:緩動指定對象中相應(yīng)顏色屬性的值(TweenMax.to(my_obj,{hexColors:{mycolor:0Xff0000}}))
? ? onStart:Function:在緩動開始時想要執(zhí)行的某個函數(shù)
?? ? onStartParams:Array:緩動開始時要執(zhí)行函數(shù)的參數(shù)
?? ? onUpdate:Function:緩動過程中,每次更新屬性值時,要執(zhí)行的函數(shù)
? ? onUpdateParams:Array:同上。。
? ? onComplete:Function:緩動結(jié)束時要執(zhí)行的函數(shù)
?? ? onCompleteParams:Array:同上。。?? ?
?? ? renderOnStart:Boolean:阻止緩動的渲染效果直到緩動真正開始
? ? overwrite:Boolean:緩動效果是否可以被覆蓋
? ? blurFilter:Object:應(yīng)用模糊濾鏡,需要傳遞一個具有下列屬性的對象作為參數(shù):blurX(橫向的模糊度),blurY(縱向的模糊度),quality(品質(zhì),默認值為2)
? ? glowFilter:Object:應(yīng)用發(fā)光濾鏡,需要傳遞一個帶有以下屬性的對象:alpha,blurX,blurY,color,strength(強度),quality,inner(內(nèi)側(cè)發(fā)?? ? ?? ? ?? ? 光),knockout(挖空)
?? ? colorMatrixFilter:Object:應(yīng)用顏色矩陣濾鏡,需要傳遞一個帶有以下屬性的對象:colorize(色調(diào)),amount(總量),contrast(對比度),brightness(亮度),saturation(飽和度),hue(色相),threshold(閥值),relative(相關(guān)性),matrix(顏色矩陣)
?? ? dropShadowFilter:Object:應(yīng)用陰影濾鏡,需要傳遞一個帶有以下屬性的對象:alpha,angle(角度),blurX,blurY,color,distance(距離),strength,quality
?? ? bevelFilter:Object:應(yīng)用斜角濾鏡,需要傳遞一個帶有以下屬性的對象:angle,blurX,blurY,distance,hightlightAlpha(高亮區(qū)的透明度),highlightColor(高亮區(qū)的顏色),shadowAlpha(陰影區(qū)的透明度),shadowColor(陰影區(qū)的顏色),strength(強度),quality

?? ? progress:Number:緩動進程0~1
?? ? paused:Boolean:是否停止緩動

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

6)getTweensOf(target:Object):Array
?返回運動物體正在運行的的TweenMax Object
7)isTweening(target:Object):Boolean
?判斷是否正在緩動
8)?updateTo(vars:Object, resetDuration:Boolean = false):void
?可以在運行中新增或改變原有的屬性變化值。第二個參數(shù)設(shè)為false時將不重播緩動,而繼續(xù)緩動到新的值;設(shè)為true將中斷并重播緩動。

三、Tweenlite的用法

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

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

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

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

如果希望使用更高級的緩動函數(shù)在 5 內(nèi),將 alpha 變到 0.5,將 x 移動 到 120 ,使用 “easeOutBack” 彈性函數(shù),緩動整體延遲 2 秒發(fā)生,并且在緩動結(jié)束時,執(zhí)行 “onFinishTween” 函數(shù),并且為這個函數(shù)傳遞幾個參數(shù),(一個數(shù)值 5 以及對 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);
}

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

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

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

應(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});
}
在舞臺上點擊,會讓mc 元件旋轉(zhuǎn)并跑動到鼠標位置。



總結(jié)

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

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