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

  1. Very good info. Lucky me I recently found your blog by chance (stumbleupon). I’ve book-marked it for later!

  2. 匿名訪客表示:

    Wonderful post. It’s extremely articulate and filled with valuable details. Thanks for offering this information.

  3. An intriguing discussion is definitely worth comment. I do think that you ought to publish more on this topic, it may not be a taboo subject but generally people do not speak about these topics. To the next! All the best.

  4. This is highly enlightening. I truly enjoyed going through it. The information is extremely arranged and straightforward to follow.

  5. Inidwx表示:

    buy colospa 135 mg online cheap – purchase mebeverine sale pletal 100 mg ca

  6. Good work, I enjoyed – Gulvafslibning | Kurt Gulvmand. It was good. View my blog sometime, it all about Winter Springs, FL Real Estate.

  7. Hello there! This post could not be written any better! Reading through this post reminds me of my previous roommate! He continually kept preaching about this. I am going to send this article to him. Fairly certain he’ll have a great read. Thanks for sharing!

  8. Right here is the right website for everyone who wants to understand this topic. You realize so much its almost hard to argue with you (not that I actually would want to…HaHa). You definitely put a new spin on a subject that’s been written about for a long time. Excellent stuff, just wonderful.

  9. Профессиональный сервисный центр по ремонту ноутбуков, макбуков и другой компьютерной техники.
    Мы предлагаем:ремонт макбука в москве
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  10. 33win表示:

    May I just say what a relief to uncover an individual who truly understands what they are discussing on the net. You definitely realize how to bring a problem to light and make it important. More and more people ought to look at this and understand this side of the story. I was surprised you aren’t more popular since you certainly possess the gift.

  11. Профессиональный сервисный центр по ремонту сотовых телефонов, смартфонов и мобильных устройств.
    Мы предлагаем: ремонт телефонов по близости
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  12. A fascinating discussion is definitely worth comment. There’s no doubt that that you ought to write more about this issue, it might not be a taboo matter but typically folks don’t discuss such topics. To the next! Kind regards.

  13. Профессиональный сервисный центр по ремонту сотовых телефонов, смартфонов и мобильных устройств.
    Мы предлагаем: ремонт мобильных
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  14. sex表示:

    After going over a few of the blog posts on your web page, I really appreciate your technique of writing a blog. I saved it to my bookmark webpage list and will be checking back soon. Take a look at my website too and tell me your opinion.

  15. sex表示:

    Having read this I believed it was really enlightening. I appreciate you spending some time and effort to put this content together. I once again find myself personally spending a significant amount of time both reading and posting comments. But so what, it was still worthwhile!

  16. ngentot表示:

    Excellent article! We will be linking to this particularly great content on our site. Keep up the good writing.

  17. TK88表示:

    I wanted to thank you for this wonderful read!! I absolutely enjoyed every bit of it. I have got you bookmarked to check out new stuff you post…

  18. I couldn’t refrain from commenting. Very well written!

  19. I was excited to uncover this web site. I want to to thank you for ones time for this wonderful read!! I definitely appreciated every bit of it and I have you book marked to check out new things on your blog.

  20. Tpower Login表示:

    I couldn’t resist commenting. Perfectly written.

  21. Dcravc表示:

    celecoxib pills – buy cheap indomethacin indomethacin oral

  22. After exploring a number of the articles on your web page, I seriously like your technique of writing a blog. I saved as a favorite it to my bookmark site list and will be checking back in the near future. Take a look at my website as well and tell me your opinion.

  23. Hello there! This post couldn’t be written much better! Looking at this post reminds me of my previous roommate! He continually kept preaching about this. I am going to send this article to him. Pretty sure he’ll have a very good read. Many thanks for sharing!

  24. Aw, this was a really nice post. Taking the time and actual effort to generate a very good article… but what can I say… I put things off a lot and never manage to get nearly anything done.

  25. Way cool! Some very valid points! I appreciate you writing this post plus the rest of the website is extremely good.

  26. Your style is very unique in comparison to other folks I have read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I will just book mark this web site.

  27. Sv522表示:

    A motivating discussion is worth comment. I do think that you need to publish more about this subject, it might not be a taboo matter but usually people don’t discuss such topics. To the next! Cheers!

  28. Greetings! Very helpful advice in this particular article! It is the little changes that make the most significant changes. Thanks for sharing!

發佈留言

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