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

  1. Walterrinia表示:

    https://zithromax.best/# zithromax coupon

  2. Walterrinia表示:

    https://antibiotic.best/# where to buy amoxicillin 500mg without prescription

  3. gacorslot表示:

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

  4. XsaYrddLiZgt表示:

    On this site u can buy all known Killa for very good price!

  5. scb99表示:

    Hi my family member! I want to say that this article is amazing, great written and include approximately all important infos. I’d like to see more posts like this .

  6. Vhkate表示:

    buy zofran for sale simvastatin 20mg cost zocor cost

  7. ascetacle表示:

    Frequently Asked Questions lasix iv to po ratio 2007 Feb; 18 2 317 23

  8. Ginniepisn表示:

    help me write a essay
    help writing a narrative essay
    online essay writing service

  9. Ginniepisn表示:

    write my admission essay
    cheap custom essay
    cheap custom essay writing service

  10. XsaYrolLiZgt表示:

    On this site u can buy all known killa snus for very good price!

  11. Hekmgv表示:

    mobic price buy meloxicam 15mg online cheap flomax 0.2mg cost

  12. XsaYaylLiZgt表示:

    On this site u can buy all known KILLA COLD MINT for very good price!

  13. Ginniepisn表示:

    best writing service
    buy custom essay online
    essay help 123

  14. Great post. Just a heads up – I am running Ubuntu with the beta of Firefox and the navigation of your blog is kind of broken for me.

  15. For newest information you have to pay a quick visit the web and on world-wide-web I found this
    web site as a best web site for most recent updates.

  16. lonpao表示:

    I encountered your site after doing a search for new contesting using Google, and decided to stick around and read more of your articles. Thanks for posting, I have your site bookmarked now.

  17. I like your quality that you put into your writing . Please do continue with more like this.

  18. ScottOxind表示:

    https://stromectolivermectin.pro/# ivermectin lice oral

  19. Martinaback表示:

    https://buytadalafil.icu/# tadalafil 20 mg best price

  20. FrankTrasp表示:

    https://buysildenafil.best/# cheap sildenafil 100

  21. Gtrimn表示:

    levaquin 500mg without prescription cheap avodart order ranitidine 150mg online

  22. FrankTrasp表示:

    https://buysildenafil.best/# sildenafil 40 mg over the counter

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

  24. tuberia cobre表示:

    I would share your post with my sis.

  25. AndrewBix表示:

    https://pillswithoutprescription.xyz/# buy cheap prescription drugs online

  26. ScottOxind表示:

    https://stromectolivermectin.pro/# ivermectin tablets uk

  27. FrankTrasp表示:

    https://buysildenafil.best/# sildenafil 10 mg price

  28. Ginniepisn表示:

    essay writing service canada
    essay writing help
    essayhelp

  29. ScottOxind表示:

    https://stromectolivermectin.pro/# ivermectin 5 mg price

發佈回覆給「XsaYrolLiZgt」的留言 取消回覆

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