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

2,904 Responses

  1. Lettipisn表示:

    dating women online
    mature nl free
    40 online dating

  2. Petercof表示:

    https://hydroxychloroquine.icu/# plaquenil 200mg cost

  3. ThomasPoire表示:

    https://tadalafil.pro/# generic tadalafil 20mg canada

  4. Greetings! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative in a community in the same niche. Your blog provided us beneficial information. You have done a wonderful job!

  5. Your idea is outstanding; the issue is something that not enough persons are speaking intelligently about. I’m very happy that I stumbled throughout this in my seek for one thing regarding this.

  6. American Crisis Prevention and Management Association Management of Assaultive Behavior (MAB) certification course can be conveniently done online or in the classroom. Also known as AB 508 certification training, mab certification online or managing aggressive behavior is a training for healthcare professionals, teachers, law enforcement agents., and other individuals that come in contact with potential aggression. Nurses, doctors and other healthcare professionals receive CE credits at the end of the course. Enroll now at https://crisispreventionmanagement.com/mab-management-of-assaultive-behavior

  7. Prvswv表示:

    red dog casino online casinos real money help with term papers

  8. Casandrapisn表示:

    casinos online real money no deposit
    usa casinos
    best casino bonus

  9. Karrypisn表示:

    dating online
    online dating web site
    chinese dating show

  10. Your resources are well developed.

  11. nuestra web表示:

    I thought it was going to be some boring old post, but I’m glad I visited. I will post a link to this site on my blog. I am sure my visitors will find that very useful.

  12. ThomasPoire表示:

    https://sildenafil.pro/# sildenafil tablets in india

  13. Petercof表示:

    https://tadalafil.pro/# buy tadalafil from india

  14. Kyrstinpisn表示:

    turns to gay sex dating
    newest gay dating site
    victim met killer on gay dating site new yorlk

  15. HenryNew表示:

    sildenafil 20 mg online canadian prices for sildenafil

  16. I was reading through some of your content on this internet site and I believe this web site is very informative ! Continue posting .

  17. cheap rdp表示:

    Might we expect to see more of these same problems in the future?

  18. Emaliapisn表示:

    dating kostenlos in sz
    asians dating site
    dating web site

  19. Futnbg表示:

    sildenafil on line cialis online buy tadalafil 20mg over the counter

  20. The Playground is a young actor’s conservatory: a place where actors are immersed in the craft of Television and Film Acting. Young people of all ages look forward to coming here and taking part in our carefully developed curriculum, a curriculum that has been personally designed by Gary Spatz. Gary Spatz, the founder of The Playground, is one of the top child acting coaches in the world and has 25 years of experience working with children in the entertainment industry. Projects include: The Mickey Mouse Club, Suite Life, Roseanne, Everybody Loves Raymond and many more. Gary is sought after to work with young actors for film and television projects. He has worked with many of the most successful young performers in Hollywood from Britney, Christina and Justin to Dylan and Cole!

  21. Jeraleepisn表示:

    gay male dating
    gay dating show youtube
    free gay online dating by zip code

  22. Appreciation for taking the time to discuss this topic, I would love to discover more on this topic. If viable, as you gain expertise, would you object to updating the website with further information? It is tremendously beneficial for me.

  23. Chelsaepisn表示:

    12 single dating site
    dating website free
    plentyoffish login

  24. swing表示:

    Great info! Keep post great articles.

  25. Petercof表示:

    https://sildenafil.pro/# generic 100mg sildenafil

  26. ThomasPoire表示:

    https://sildenafil.pro/# sildenafil citrate 50 mg

  27. Nnvqds表示:

    buy zanaflex for sale oral inderal 10mg order reglan 20mg

  1. 2022-08-30

    guts casino online chat https://onlinecasinos4me.com/

  2. 2022-08-30

    river belle online casino https://online2casino.com/

  3. 2022-08-30

    casino games online real money https://casinosonlinex.com/

發佈留言

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