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

  1. IWIN表示:

    I’m impressed, I have to admit. Seldom do I encounter a blog that’s both equally educative and amusing, and without a doubt, you have hit the nail on the head. The problem is something that too few people are speaking intelligently about. I’m very happy I came across this in my search for something concerning this.

  2. This website was… how do you say it? Relevant!! Finally I’ve found something which helped me. Thank you.

  3. lehenga表示:

    After I originally left a comment I seem to have clicked on the -Notify me when new comments are added- checkbox and now every time a comment is added I recieve four emails with the same comment. Is there a way you are able to remove me from that service? Kudos.

  4. Pzshob表示:

    noroxin tablets – buy confido buy confido pill

  5. Greetings! Very helpful advice in this particular post! It’s the little changes which will make the largest changes. Many thanks for sharing!

  6. iptv表示:

    This is a topic that is near to my heart… Best wishes! Where can I find the contact details for questions?

  7. iptv表示:

    Hi there! I simply want to offer you a huge thumbs up for your great info you have got here on this post. I’ll be coming back to your website for more soon.

  8. iptv表示:

    Pretty! This has been a really wonderful post. Thank you for supplying this information.

  9. sex表示:

    That is a good tip particularly to those new to the blogosphere. Short but very accurate information… Thanks for sharing this one. A must read post.

  10. trani表示:

    To reduce errors, fraud, and delays for payments authorized over the internet, Nacha (the organization that oversees the ACH network), put a new rule into effect in 2021. This rule requires originators of WEB transactions to verify the recipient’s account is open, valid, and able to receive ACH transfers—before initiating an ACH debit that was authorized by a consumer online. “The addition of USD fiat withdrawal via international bank transfer is a frequently requested feature that further strengthens the utility of Crypto platform,” it said. Using a credit card to buy crypto can come with high fees, typically around 4% or higher. These fees can add up quickly, especially if you make frequent purchases or buy large amounts of crypto. Dedicated crypto and bitcoin exchanges will allow you to withdraw your crypto funds and transfer them to another wallet of your choice. Others, especially those that focus on other assets, like stocks and ETFs — including Robinhood and eToro — only let you purchase the crypto but not transfer it out of their web wallets.
    https://www.cheaperseeker.com/u/gulcontlecsi1987
    Depuis les débuts du bitcoin jusqu’à la prolifération des nouvelles monnaies aujourd’hui, le piratage est resté un problème majeur pour les investisseurs en crypto-monnaies. Chaque piratage du système, des échanges ou des portefeuilles de crypto-monnaies a provoqué un effondrement des prix. Récemment, une attaque contre la bourse de crypto-monnaies binance a provoqué une chute de 10,8 % en quelques minutes. Join the Chatt Major League Bitcoin This table lists the real-time conversion rate of Euro (EUR) into Bitcoin (BTC) for many of the most used multiples. The real-time conversion rate of Bitcoin (BTC) to EUR is €61,782.81 for every 1 BTC. The table below shows the live rate to convert different amounts, such as 5 BTC into EUR.

  11. When I originally left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. There has to be a way you are able to remove me from that service? Kudos.

  12. near me表示:

    Good article. I will be facing a few of these issues as well..

  13. kontol表示:

    I could not refrain from commenting. Perfectly written!

  14. I’m going to share this on social media.검색엔진최적화 배우기

  15. Mlgsix表示:

    cheap lasuna for sale – purchase lasuna generic buy himcolin no prescription

  16. I would like to thank you for the efforts you’ve put in writing this blog. I’m hoping to check out the same high-grade blog posts from you later on as well. In fact, your creative writing abilities has motivated me to get my own, personal website now 😉

  17. seo 백링크表示:

    Your article has broadened my understanding.백링크 작업

  18. Card game表示:

    Howdy! I could have sworn I’ve been to this site before but after looking at some of the articles I realized it’s new to me. Anyways, I’m certainly happy I came across it and I’ll be bookmarking it and checking back often.

  19. AI for Kids表示:

    Hi! I could have sworn I’ve visited this site before but after looking at some of the posts I realized it’s new to me. Anyhow, I’m certainly delighted I discovered it and I’ll be bookmarking it and checking back often.

  20. hishypesports表示:

    Way cool! Some very valid points! I appreciate you writing this article and also the rest of the website is really good.

  21. Xwglde表示:

    order gasex without prescription – ashwagandha online order cheap diabecon generic

  22. Having read this I thought it was very informative. I appreciate you finding the time and effort to put this information together. I once again find myself spending a lot of time both reading and posting comments. But so what, it was still worth it!

  23. iwin68表示:

    Hi there! This blog post couldn’t be written any better! Reading through this post reminds me of my previous roommate! He continually kept preaching about this. I will send this post to him. Fairly certain he will have a very good read. Many thanks for sharing!

  24. kontol表示:

    Pretty! This has been an extremely wonderful post. Many thanks for providing this info.

  25. link bokep表示:

    You made some good points there. I looked on the web for more info about the issue and found most individuals will go along with your views on this website.

  26. ngentot memek表示:

    Saved as a favorite, I love your site.

發佈留言

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