利用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...

10,160 Responses

  1. Calvindit表示:

    impotence pills erection pills

  2. I truly appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thank you again

  3. Nanicepisn表示:

    order cheap essay
    cat essay writer
    cat essay writer

  4. 야동데이表示:

    I appreciate your work, thanks for all the great blog posts.

  5. Zazujb表示:

    order tacrolimus 1mg for sale requip 1mg pill order tricor 200mg online

  6. Charitapisn表示:

    buy college essay
    best custom essay service
    professional essay writers for hire

  7. Calvindit表示:

    the canadian pharmacy best canadian online pharmacy

  8. safetoto表示:

    Your writing is perfect and complete. safetoto However, I think it will be more wonderful if your post includes additional topics that I am thinking of. I have a lot of posts on my site similar to your topic. Would you like to visit once?

  9. Charitapisn表示:

    cheap essay papers
    can someone write my essay for me
    help with writing essays

  10. Luizmi表示:

    cost irbesartan 150mg buy irbesartan generic famotidine 20mg pill

  11. I’ve thought about posting something about this before. Good job! Can I use part of your post in my blog?

  12. Ashlenpisn表示:

    best essay writer service
    custom made essays
    cheap essay writer

  13. Ayxovn表示:

    buy clarinex sale arcoxia online buy generic asacol 400mg

  14. Calvindit表示:

    canadian pharmacy without prescription canadian pharmacy no prescription needed

  15. Thanks a bunch for sharing this with all people you really recognize what you are talking about! Bookmarked. Kindly also seek advice from my web site =). We can have a link alternate contract between us!

  16. Merolapisn表示:

    essay paper help
    best college essay writing service
    college admission essay editing services

  17. We can see that we need to develop policies to deal with this trend.

  18. Martypisn表示:

    essay writing service us
    persuasive essay help
    essay correction service

  19. Spkwiy表示:

    order atorvastatin 80mg sale lyrica online order lyrica 150mg ca

  20. If you don’t mind, where do you host your weblog? I am looking for a very good web host and your webpage seams to be extremely fast and up most the time…

  21. Calvindit表示:

    ed medications list top ed drugs

  22. A neighbor of mine encouraged me to take a look at your blog site couple weeks ago, given that we both love similar stuff and I will need to say I am quite impressed.

  23. En Ateşli Porno Videolar Aşağılama (87) Eklenme tarihi.
    Sıcak porno film. 100%; 1. Erotik Canlı Sohbet.
    Tüm modeller en az 18 yaşında veya daha büyük.

  24. Dorolisapisn表示:

    help my essay
    who can help me write an essay
    mba application essay writing service

  25. Parlak çıplak külotlu çoraplı üvey annenin bacaklarını sikiyor.
    119.956 98 %. fansly. Subscribe 20.3K. 4K Porno.
    Amatör. CFNM. Genç (18+) HD Videolar.

  26. Fxpymt表示:

    buy tizanidine 2mg online brand cialis 5mg cost tadalafil 10mg

  27. Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thank you

發佈回覆給「exit cleaning service」的留言 取消回覆

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