利用Tweener製作動畫 – 數大便是美

套用徐志摩的名言:「數大」便是美,意思是說數量多就是美,不過雖然數大便是美,但如果要針對多個元件製作動畫,那利用程式一定會比手工來的輕鬆,甚至可以更漂亮和壯觀,以下的範例就是利用Tweener針對較多的元件來製作動畫的結果,分享給大家參考!希望各位未來不會「數大」便是累。

Tweener 滿天星斗:利用Tweener針對星形製作Alpha動畫,是一個很簡單的範例。

import caurina.transitions.Tweener
import flash.display.MovieClip;

setInterval(starFn,50)
function starFn(){
	var scale:Number=Math.random()
	var mc:MovieClip=new star
	mc.x=Math.random()*500
	mc.y=Math.random()*500
	mc.scaleX=scale
	mc.scaleY=scale
	mc.alpha=0
	addChild(mc)
	Tweener.addTween(mc, {alpha:1, time:7, transition:"linear"});
	Tweener.addTween(mc, {alpha:0, time:3,delay:8, transition:"linear"});
}

滿天星斗 原始檔 下載


Tweener 擴散效果:利用Tweener針對球體來製作動畫,其中還應用到距離計算的Class,可以試著調整參數(彈出距離變數、彈出數量…等)來觀察改變的情況。

import flash.display.Sprite;
import roMc;
import flash.geom.Point;
import caurina.transitions.Tweener;

//變數定義區塊
var centerPoint:Point = new Point  ;//圓形中心點
var i:int = 1;//迴圈變數
var radius:int = 50;//彈出距離變數
var no:int = 20;//彈出數量
var circleArray:Array=new Array//球體陣列(針對移除使用)
var sec:int=1//動畫秒數
var hold:Number=0.1//延遲秒數

centerPoint.x = stage.stageWidth / 2;
centerPoint.y = stage.stageHeight / 2;

stage.addEventListener(MouseEvent.CLICK,clickFn);

function clickFn(e:MouseEvent)
{
	while (circleArray.length > 0) {
			removeChild(circleArray.pop());
	}
	Tweener.removeAllTweens();
	showFn();
}

function showFn()
{
	for (i=1; i<=no; i++)
	{
		var mc:Sprite = new ball  ;
		circleArray.push(mc)
		var angle:Number = 2 * Math.PI / no * i;
		var targetPoint:Point = new Point();
		targetPoint.x = radius * Math.cos(angle) + centerPoint.x;
		targetPoint.y = radius * Math.sin(angle) + centerPoint.y;
		addChild(mc);
		mc.x = centerPoint.x;
		mc.y = centerPoint.y;
		mc.alpha = 0;
		Tweener.addTween(mc, {alpha:1,x:targetPoint.x,y:targetPoint.y, time:sec, transition:"linear",delay:i*hold});
		Tweener.addTween(mc, {alpha:0,x:centerPoint.x,y:centerPoint.y, time:sec, transition:"linear",delay:i*hold+(no*hold+1)});
	}
}

擴散效果 原始檔 下載

You may also like...

14,723 Responses

  1. Fantastic piece of writing here1

  2. BrandenBaX表示:

    buy cipro ciprofloxacin generic price

  3. Certainly. And I have faced it. Let’s discuss this question. Here or in PM.

  4. Nqivqm表示:

    azathioprine 50mg canada telmisartan 80mg tablet buy telmisartan online

  5. Keep it up!. I usually don’t post in Blogs but your blog forced me to, amazing work.. beautiful A rise in An increase in An increase in.

  6. Emaleepisn表示:

    chicago gay chat rooms free
    gay fl chat
    gay chat with married man

  7. Josephamirm表示:

    legit canadian pharmacy best online pharmacy india

  8. RaymondNor表示:

    https://ciprofloxacin.icu/# buy ciprofloxacin

  9. kiscill表示:

    For the case of impotence, Viagra s active ingredient acts as a PDE5 inhibitor can priligy cure pe

  10. I am glad to be a visitor of this perfect blog !, appreciate it for this rare info!

  11. Vclub表示:

    If wings are your thing, Tinker Bell’s sexy Halloween costume design is all grown up.

  12. Fybneq表示:

    help writing papers for college order generic tadalafil cialis 40mg drug

  13. pagina web表示:

    Have you given any kind of thought at all with converting your current web-site into French? I know a couple of of translaters here that will would certainly help you do it for no cost if you want to get in touch with me personally.

  14. leer mas表示:

    We’re developing some community services to respond to this, and your blog is helpful.

  15. click aqui表示:

    Fantastic piece of writing here1

  16. empresa表示:

    Spot on with this write-up, I actually assume this website needs far more consideration. I will in all probability be once more to learn rather more, thanks for that info.

  17. informate表示:

    Clear, concise and easy to access.

  18. empresa表示:

    It’s time for communities to rally.

  19. Deeynpisn表示:

    gay phone chat lines with free trials
    gay chat louisiana
    gay video chat for windows 8

  20. pagina web表示:

    Is it okay to put a portion of this on my weblog if perhaps I post a reference point to this web page?

  21. Thank you for sharing this very good post. Very interesting ideas! (as always, btw)

  22. joy rummy表示:

    I concur with your conclusions and will eagerly look forward to your future updates. The usefulness and significance is overwhelming and has been invaluable to me!

  23. Genniepisn表示:

    gay chatroulette chat
    gay cruising chat
    miai chat gay

  24. I loved your idea there, I tell you blogs are so exciting sometimes like looking into people’s private life’s and work. Every new remark wonderful in its own right.

  25. Some genuinely choice content on this site, bookmarked .

  26. Rustimi表示:

    Sildenafil and vardenafil can be taken once per day, though you plan to take it when you want the effects to happen a window of about 4-6 hours buy generic cialis online cheap For testing services, does the company adhere to the latest and most advanced testing technologies and achieve a very high degree of accuracy

  1. 2022-09-03

    boy self sucking chat room gay chum’s brother calhoun couldn’t stop https://gaychatcams.net/

  2. 2022-09-03
  3. 2022-09-03

    ontario calif gay chat room https://gay-live-chat.net/

  4. 2022-09-04

    gay videeo chat https://chatcongays.com/

發佈留言

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