[心得] Tween class實際操作
接著是Tween class的實作
假如我場上有一個叫做my_mc的MovieClip
然後我希望它的_x可以在兩秒內從10漸變成50
那我只要輸入以下的code就可以達成這個效果
import mx.transitions.Tween;
var motion:Tween = new Tween(my_mc, "_x", null, 10, 50, 2, true);
在此easeFunction變數我輸入了null
那表示不會有任何的漸變特效
但是easeFunction到底要怎麼用呢?
Flash已經內建了許多easeFunction class
他們都位於 mx.transitions.easing 這個package裡面
分別是 mx.transitions.easing.Back
mx.transitions.easing.Bounce
mx.transitions.easing.Elastic
mx.transitions.easing.Regular
mx.transitions.easing.Strong
其中又都有 easeIn(起步), easeOut(收尾), easeInOut(起步&收尾) 三種method
Back 是tween motion執行後還會"超過endValue然後回彈一下"
Bounce 是tween motion執行後還會"達到endValue然後往回彈幾下"
Elastic 是tween motion執行後還會"在endValue做阻尼震盪"
Regular 是tween motion執行時"產生漸快/慢等效果"(看你是用哪個method)
Strong 是Regular的強化版,漸快/慢感覺比較"暴力"
當我把code變成(藍字為 新增/修正 的部份)
import mx.transitions.Tween;
import mx.transitions.easing.*;
var motion:Tween = new Tween(my_mc, "_x", Strong.easeInOut, 10, 50, 2, true);
就會看出明顯的"起步&收尾"漸變特效
大家可以自己來試試看
同樣避免文章太長...實際範例會在下篇po上
--
CJ Cat = Croa'J Cat = Cockroach Cat = 西街凱特 = 蜚蠊貓 = 蟑螂貓
Gallery http://cjcat2266.deviantart.com
MSN cjcat2266@hotmail.com
Yahoo cjcat2266@yahoo.com.tw
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.86.183
※ 編輯: cjcat2266 來自: 61.228.72.24 (07/25 20:15)
Flash 近期熱門文章
PTT數位生活區 即時熱門文章