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

15,929 Responses

  1. geinoutime.com
    Hongzhi 황제는 “이것이 당신의 생각입니까, 아니면 Jifan의 생각입니까? “라고 말했습니다.

  2. EdwardGROOM表示:

    Sildenafil teva 100 mg sans ordonnance: viagra sans ordonnance – SildГ©nafil 100 mg sans ordonnance

  3. Allenacurf表示:

    Achat mГ©dicament en ligne fiable: Levitra acheter – pharmacie en ligne livraison europe

  4. Allenacurf表示:

    Viagra sans ordonnance livraison 24h: viagra en ligne – Viagra pas cher livraison rapide france

  5. Eu recomendo o melhor cassino Fortune Tiger

  6. EdwardGROOM表示:

    SildГ©nafil Teva 100 mg acheter: Meilleur Viagra sans ordonnance 24h – Viagra 100mg prix

  7. KeithKef表示:

    pharmacie en ligne avec ordonnance Levitra pharmacie en ligne trouver un mГ©dicament en pharmacie

  8. Ignacioreura表示:

    trouver un mГ©dicament en pharmacie: pharmacie en ligne pas cher – Pharmacie Internationale en ligne

  9. IgnacioSlima表示:

    pharmacie en ligne: Cialis sans ordonnance 24h – acheter mГ©dicament en ligne sans ordonnance

  10. KeithKef表示:

    Pharmacie Internationale en ligne Acheter Cialis 20 mg pas cher pharmacie en ligne pas cher

  11. Ignacioreura表示:

    vente de mГ©dicament en ligne: levitra generique – Pharmacie sans ordonnance

  12. zamki_mpPn表示:

    вскрыть замок ключа famagusta-nedvizhimost2.ru .

  13. zamki_qtPn表示:

    вскрыть замок ключа http://www.famagusta-nedvizhimost2.ru .

  14. Roberthep表示:

    pharmacie en ligne pas cher Pharmacie en ligne livraison Europe acheter mГ©dicament en ligne sans ordonnance

  15. AntoniaSut表示:

    farmacia online 24 horas: farmacia online barata y fiable – farmacia online 24 horas

  16. Urzsrw表示:

    prostatitis pills lend – prostatitis pills thomas prostatitis medications thank

  17. Roberthep表示:

    top farmacia online acquistare farmaci senza ricetta farmacie online autorizzate elenco

  18. Great site ! I recommend this site!https://puffbars.uk/

  19. WilliamTeath表示:

    Farmacie on line spedizione gratuita: farmaci senza ricetta elenco – farmaci senza ricetta elenco

  20. Cutting-edge Crypto Gambling Platform ”

    You should check out this newest crypto betting ! They are super cool . You can play for without paying and get gratis spins without giving them all your personal particulars . Plus, they give you a discount just for signing up – no deposit needed! The games are unbiased and uncomplicated to play. And you can even receive dough by telling your friends about the online casino through their affiliate betting networks. It’s the best spot to have fun and maybe score big . What are you hesitating for? Go try it immediately!

    Here is my web-site :: no deposit bonus crypto casino

  21. Donaldcoums表示:

    beste online-apotheke ohne rezept: apotheke online – ohne rezept apotheke

  22. O cassino mais confiavel Fortune Tiger

  23. Melhor cassino para ganhar Fortune Tiger

  24. Roberthep表示:

    pharmacie en ligne france livraison belgique п»їpharmacie en ligne france pharmacie en ligne france livraison belgique

  25. AntoniaSut表示:

    farmacias online baratas: farmacia en casa online descuento – farmacias online seguras

  26. Eu recomendo o melhor cassino Fortune Tiger

  27. WilliamTeath表示:

    farmacie online autorizzate elenco: comprare farmaci online all’estero – comprare farmaci online all’estero

發佈留言

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