利用Tweener製作動畫 – 其他參數

因為這陣子馬老師擔任了崇右數位媒體設計系的系主任後業務繁忙,好久沒在部落格上貼文章了,現在總算有些空檔可以繼續貼文,之前寫了有關利用Tweener製作動畫的文章,接著這篇文章來介紹在Tweener中其他可用的參數,請各位參考,不過詳細的部分還是可以參考官網的說明。


delay:可以設定在動畫完成後多久,再接續進行下一動畫(Tweener delay 範例

import caurina.transitions.Tweener

Tweener.addTween(ball, {x:150, time:1});
//用一秒鐘的時間移動ball元件至x為150的位置
Tweener.addTween(ball, {y:100, time:1, delay: 2});
//等待兩秒後用一秒鐘的時間移動ball元件至y為100的位置

getTweenCount:取得目前動畫的補間數量(Tweener getTweenCount 範例

import caurina.transitions.Tweener

Tweener.addTween(ball, {x:150, time:2});
Tweener.addTween(ball, {y:100, time:2,delay:2});
txt.text="元件Ball共有" + Tweener.getTweenCount(ball) + "段補間動畫"

getTweens:取得目前動畫所更改元件的屬性(Tweener getTweens 範例

import caurina.transitions.Tweener

Tweener.addTween(ball, {x:150, y:100, alpha:1, time:2});
txt.text="元件Ball共被製作了" + Tweener.getTweens(ball) + "的屬性變化"
//輸出元件被補間的屬性

getVersion:取得目前使用Tweener的版本(Tweener getVersion 範例

import caurina.transitions.Tweener

Tweener.addTween(ball, {x:150, y:100, time:2});
txt.text="本動畫使用Tweener版本為:" +Tweener.getVersion()
//輸出元件使用Tweener的版本

onStart、onUpdate、onComplete:分別在補間「開始」、「進行中」、「結束」呼叫不同的函數執行(Tweener complex 範例

import caurina.transitions.Tweener
import flash.events.MouseEvent;

Tweener.addTween(ball, {x:150, y:100, time:3,onStart:startFn,onUpdate:updateFn,onComplete:completeFn});
/*用三秒鐘的時間移動ball元件至x為150和y為100的位置
開始時執行startFn函數
過程中執行updateFn函數
完成後執行completeFn函數
*/
function startFn(){
	ball.alpha=0.1
}

function updateFn(){
	ball.alpha+=0.02
	txt.text="球體正在移動"
}

function completeFn(){
	ball.alpha=1
	txt.text="現在可以拖曳球體"
	ball.addEventListener(MouseEvent.MOUSE_DOWN,downFn)
	ball.addEventListener(MouseEvent.MOUSE_UP,upFn)
	function downFn(e:MouseEvent){
		ball.startDrag()
	}
	function upFn(e:MouseEvent){
		ball.stopDrag()
	}
}

addCaller:在指定的時間內呼叫某函數N次(Tweener addCaller 範例

import caurina.transitions.Tweener
var i=0
no.text=i
Tweener.addCaller(no, {onUpdate:go, time:10, count:10 , transition:"linear"});
//在10秒內針對no執行10次go函數
//Tweener.addCaller(no, {onUpdate:go, time:10, count:10 , transition:"easeinquad"});
//在10秒內針對no執行10次go函數且速度越來越慢

function go(){
	i++
	no.text=i
}

controlTweens:控制由Tweener所產生的動畫(Tweener controlTweens 範例

import caurina.transitions.Tweener

Tweener.addTween(ball, {x:280, time:20,transition:"linear"});

pauseBtn.addEventListener(MouseEvent.CLICK,pauseFn)
resumeBtn.addEventListener(MouseEvent.CLICK,resumeFn)

function pauseFn(e:MouseEvent){
	pauseBtn.visible=false
	resumeBtn.visible=true
	Tweener.pauseAllTweens(); 
}

function resumeFn(e:MouseEvent){
	pauseBtn.visible=true
	resumeBtn.visible=false
	Tweener.resumeAllTweens(); 
}

soundVolume:利用Tweener來控制音量(Tweener soundVolume 範例

import caurina.transitions.Tweener;
import caurina.transitions.properties.SoundShortcuts;
SoundShortcuts.init();

var snd:Sound = new heavy  ;
var chn:SoundChannel = new SoundChannel  ;
chn = snd.play(0,1000);

btn.addEventListener(MouseEvent.CLICK,clickFn)

function clickFn(e:MouseEvent){
	Tweener.addTween(chn, {_sound_volume:0, time:10});
}
//點選按鈕後聲音會在十秒內逐漸歸零

FilterShortcut:Tweener也可以控制Flash中的各種濾鏡,利用濾鏡來製作動畫或互動(blurFilter 範例dropShadowFilter 範例

blurFilter –

import flash.filters.*; 
import caurina.transitions.properties.FilterShortcuts;
import caurina.transitions.Tweener
FilterShortcuts.init();

var blur:BlurFilter=new BlurFilter

stage.addEventListener(MouseEvent.CLICK,clickFn)
function clickFn(e:MouseEvent){
	Tweener.addTween(ball, {time:0,_Blur_blurX:20,_Blur_blurY:20});
	Tweener.addTween(ball, {x:mouseX, y:mouseY, time:2,_Blur_blurX:0,_Blur_blurY:0, transition:"easeOutQuart"});
}

dropShadowFilter –

import caurina.transitions.properties.FilterShortcuts;
import caurina.transitions.Tweener
import roMc

FilterShortcuts.init();
stage.addEventListener(Event.ENTER_FRAME,shadowFn)
function shadowFn(e:Event){
	Tweener.addTween(ball, {time:0,_DropShadow_angle:roMc.ro(ball)+180,_DropShadow_distance:6});
}

以上是有關Tweener參數的一些範例,這邊也把Tweener Parameters 壓縮檔給各位,提供有興趣的同學參考。

You may also like...

3,969 Responses

  1. Dzięki za kompleksowy przewodnik po tym, czego można oczekiwać podczas wdrażania SEO.

  2. RobertSax表示:

    https://autolux-azerbaijan.com/# Pin Up Kazino ?Onlayn

  3. I’m in awe of the way you handle topics with both grace and authority.

  4. Dzięki za to, że skomplikowane tematy SEO stały się bardziej przystępne.

  5. After checking out a handful of the blog posts on your web site, I truly appreciate your way of blogging. I book marked it to my bookmark website list and will be checking back in the near future. Please visit my website too and let me know your opinion.

  6. Thank you for the sensible critique. Me & my friend were just preparing to do a little research about this. We got a book from our local library but I think I learned more from this post. I’m very glad to see such magnificent info being shared freely out there.

  7. tubidy表示:

    Hi there, I do think your web site might be having browser compatibility problems. Whenever I take a look at your web site in Safari, it looks fine however when opening in IE, it’s got some overlapping issues. I just wanted to give you a quick heads up! Aside from that, wonderful blog!

  8. Today, with all the fast way of life that everyone leads, credit cards have a big demand throughout the economy. Persons throughout every arena are using the credit card and people who not using the credit cards have arranged to apply for just one. Thanks for revealing your ideas on credit cards.

  9. cup lock表示:

    french translation is kind of hard at first but if you get used to it, then it is easy**

  10. it is always a good idea to go green because we always want to help the environment“

  11. Nice post. I learn something harder on diverse blogs everyday. It will always be stimulating to learn to read content off their writers and exercise a little something there. I’d would rather apply certain while using the content in my small weblog no matter whether you don’t mind. Natually I’ll supply you with a link with your web blog. Appreciate your sharing.

  12. Hiya very nice website!! Guy .. Excellent .. Amazing .. I will bookmark your web site and take the feeds additionally¡KI am glad to search out a lot of useful info here in the publish, we want develop extra techniques in this regard, thank you for sharing. . . . . .

  13. Very good blog post. I absolutely love this website. Keep it up!

  14. Hi! Do you know if they make any plugins to safeguard against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?

  15. Spot on with this write-up, I seriously believe this site needs far more attention. I’ll probably be back again to read through more, thanks for the advice.

  16. I want looking at and I believe this website got some really useful stuff on it! .

  17. I enjoy your composing design, do carry on creating! I will be back!

  18. It’s difficult to get knowledgeable men and women with this topic, and you appear to be what happens you are dealing with! Thanks

  19. This site can be a walk-through its the information you wanted concerning this and didn’t know who to ask. Glimpse here, and you’ll undoubtedly discover it.

  20. After exploring a few of the articles on your web site, I seriously appreciate your technique of blogging. I bookmarked it to my bookmark website list and will be checking back in the near future. Please visit my web site too and let me know what you think.

  21. The finesse with which you articulated The points has me captivated. It’s as if you’re speaking my language.

  22. business表示:

    Hello there! Do you know if they make any plugins to
    assist with Search Engine Optimization? I’m trying to get my site to rank for some targeted keywords but I’m not seeing very good success.
    If you know of any please share. Cheers! I saw similar article here

  23. The Writing is a constant source of inspiration and knowledge, like a muse that never fails to inspire. Thank you for being my muse.

  24. A fascinating discussion is definitely worth comment. I think that you need to write more on this issue, it may not be a taboo subject but generally folks don’t talk about these topics. To the next! Cheers.

  25. A fascinating discussion is worth comment. I believe that you ought to write more on this subject, it might not be a taboo subject but usually people don’t talk about these subjects. To the next! Kind regards.

  26. This post was a breath of fresh air. Thank you for The unique insights!

  27. This was for a new and credulous ‘generation’ who, I suppose, have never even heard reference made or seen so much as a parody of the series – which is most unlikely, if I might paraphrase our favorite Vulcan.

  28. I have to thank you for the efforts you have put in writing this site. I’m hoping to view the same high-grade content by you later on as well. In fact, your creative writing abilities has inspired me to get my own, personal website now 😉

  29. Odaset表示:

    purchase feldene for sale – buy exelon pills exelon 6mg sale

  30. I’m so glad I stumbled upon this article. It was exactly what I needed to read!

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。