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

23,891 Responses

  1. вывод. из. запоя. анонимно. ростов. https://www.vip.mybb.rocks/viewtopic.php?id=7670 .

  2. вывод из запоя стационарно ростов my.forum2.net/viewtopic.php?id=171 .

  3. Bradleygoath表示:

    http://indianpharmacyeasy.com/# mail order pharmacy india

  4. Тут можно преобрести сейф огнеупорный купить купить несгораемый сейф

  5. нарколог на дом вывод из запоя ростов http://www.sportandpolitics.ukrbb.net/viewtopic.php?f=24&t=17793v .

  6. вывод из запоя ростов и область вывод из запоя ростов и область .

  7. Sharon表示:

    You actually make it appear so easy together with your
    presentation but I in finding this matter to be actually one thing
    that I believe I might by no means understand. It sort of feels too
    complex and very wide for me. I’m having a look forward for your next submit, I will attempt to get the
    grasp of it!

  8. Тут можно преобрести сейф несгораемый купить сейф противопожарный

  9. Тут можно преобрести огнестойкие сейфы цена сейф огнестойкий купить

  10. Quotes表示:

    We recommend exploring the best quotes collections: What You Love Quotes From Great People

  11. JefferyTar表示:

    Online medicine home delivery: indian pharmacy easy – online shopping pharmacy india

  12. Jamiecaw表示:

    https://mexicanpharmgate.com/# п»їbest mexican online pharmacies

  13. Hurrah, that’s what I was searching for, what a data! present here at this
    website, thanks admin of this web page.

  14. Bradleygoath表示:

    https://canadiandrugsgate.com/# natural ed drugs

  15. best VPN 2025表示:

    I really like reading through an article that can make people think. Also, thanks for allowing for me to comment.

  16. LarryEvini表示:

    mexican online pharmacies prescription drugs: mexican pharmacy online medications – medicine in mexico pharmacies

  17. GlennSnofs表示:

    medication from mexico pharmacy mexican pharmacy reputable mexican pharmacies online

  18. Wrapped up Reading a Blog Post: A Formal Commentary to the Comment Section and an Invitation to Join “KING855”

    ‘After rigorously reading the blog post, I would like
    to deliver the following contribution to the section .

    Your reflections regarding the topic were quite thought-provoking .

    I found myself in alignment with a number of the assertions you brought up
    .

    It is encouraging to witness such an animated discussion unfolding.

    If you are interested in further delving into this theme, I would warmly invite
    you to join the “KING855” network . In that space, you will have
    the chance to engage with kindred spirit participants and
    delve deeper into these captivating themes .

    I am convinced your participation would be a meaningful addition to the discourse .

    I’m grateful for your remarks, and I anticipate the possibility of continuing this
    stimulating dialogue .

    my page; online betting

  19. Тут можно преобрести оружейные сейфы москва шкафы для оружия сейфы

  20. Janet表示:

    Hey just wanted to give you a quick heads up. The text in your post seem to be running off the
    screen in Opera. I’m not sure if this is a formatting issue or
    something to do with browser compatibility but I figured I’d post to let you know.
    The layout look great though! Hope you get the problem resolved soon. Many thanks

  21. This website definitely has all the info I wanted concerning this subject and didn’t know who to ask.

  22. Тут можно преобрести оружейные сейфы москва сейфов для оружия

  23. Тут можно преобрести купить сейф с доставкой в москве шкафы для оружия сейфы

發佈留言

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