利用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,964 Responses

  1. Shopping tips表示:

    Having read this I believed it was rather informative. I appreciate you finding the time and effort to put this information together. I once again find myself spending way too much time both reading and commenting. But so what, it was still worth it.

  2. win79表示:

    I’m amazed, I have to admit. Rarely do I come across a blog that’s equally educative and engaging, and without a doubt, you’ve hit the nail on the head. The problem is something not enough folks are speaking intelligently about. I’m very happy I came across this during my search for something regarding this.

  3. rikvip表示:

    Greetings! Very helpful advice within this post! It’s the little changes that produce the greatest changes. Thanks a lot for sharing!

  4. That is a good tip particularly to those new to the blogosphere. Short but very accurate info… Appreciate your sharing this one. A must read article.

  5. I truly love your blog.. Great colors & theme. Did you make this web site yourself? Please reply back as I’m planning to create my own personal blog and would love to find out where you got this from or exactly what the theme is called. Thank you.

  6. K8表示:

    Oh my goodness! Incredible article dude! Thank you so much, However I am going through issues with your RSS. I don’t understand the reason why I am unable to subscribe to it. Is there anybody else having the same RSS problems? Anybody who knows the answer can you kindly respond? Thanks.

  7. Genuinely appreciated this article. It provided a lot of valuable insights. Great effort on composing this.

  8. onbet表示:

    I was very pleased to find this page. I want to to thank you for ones time due to this wonderful read!! I definitely savored every bit of it and I have you saved to fav to look at new information on your blog.

  9. Sugar Defender original,表示:

    This is fantastic! Filled with useful details and extremely well-written. Thank you for sharing this.

    https://www.youtube.com/watch?v=DuxW6pWU1pE

  10. This post is great. I learned tons from reading it. The details is highly enlightening and structured.

  11. Gxwqrj表示:

    deflazacort price – deflazacort pill order alphagan online

  12. son ho jun表示:

    I’m impressed, I have to admit. Rarely do I come across a blog that’s both educative and amusing, and without a doubt, you have hit the nail on the head. The issue is an issue that too few people are speaking intelligently about. I’m very happy I stumbled across this during my hunt for something concerning this.

  13. Loved this article. It’s extremely well-researched and packed with helpful insights. Great effort!

  14. 78win表示:

    I blog often and I genuinely appreciate your information. This article has truly peaked my interest. I’m going to book mark your website and keep checking for new information about once per week. I opted in for your RSS feed too.

  15. The very next time I read a blog, I hope that it does not disappoint me as much as this one. After all, I know it was my choice to read through, nonetheless I actually thought you would have something useful to say. All I hear is a bunch of whining about something that you could fix if you were not too busy searching for attention.

  16. I used to be able to find good advice from your blog posts.

  17. Hi, I think your site might be having browser compatibility issues. When I look at your blog site in Ie, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, amazing blog!

  18. Yynpxq表示:

    purchase lactulose bottles – mentat drug order betahistine 16 mg generic

  19. So an wonderful post! The information provided is very beneficial and articulate. Many thanks for putting in the work to write this.

  20. Mtetxo表示:

    cyclosporine for sale online – colchicine us colchicine 0.5mg pill

  21. Pretty! This has been an incredibly wonderful post. Many thanks for supplying this info.

  22. Genuinely appreciated this post. It gave a lot of valuable insights. Great job on creating this.

  23. Great entry. I thought the information extremely helpful. Loved the method you explained everything.

  24. sunwin表示:

    It’s hard to find well-informed people for this topic, but you sound like you know what you’re talking about! Thanks

  25. when there are fund raising events in our community, i always see to it that i participate in it;

  26. When you overpay a taxation through yr, you could be allowing government entities a no cost mortgage loan.

  27. When I initially commented I appear to have clicked on the -Notify me when new comments are added- checkbox and from now on each time a comment is added I receive 4 emails with the exact same comment. There has to be an easy method you can remove me from that service? Thanks a lot.

  28. link bokep表示:

    I would like to thank you for the efforts you have put in writing this blog. I’m hoping to check out the same high-grade content from you in the future as well. In truth, your creative writing abilities has motivated me to get my own, personal site now 😉

  29. child porn表示:

    best google hacklink services.

  30. leak finding表示:

    Can I just say what a reduction to find somebody who really is aware of what theyre speaking about on the internet. You definitely know the right way to carry a difficulty to mild and make it important. More people must learn this and perceive this facet of the story. I cant imagine youre no more in style since you definitely have the gift.

發佈留言

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