基于TweenMax的一个烟花效果模仿
作者:admin 日期:2013-02-18在国外的网站看到很炫的烟花效果,于是自己模仿了一个。因为只是练习一下时间线操作,因此对于细节没有追求到极致。看起来国外作品的散开点更清晰,另外烟花的随机元素更多。我这个只是简单的控制了一下几个随机因素。
国外作品:
我的仿作(点击舞台放烟花):
XML/HTML代码
- package {
- import com.greensock.TweenMax;
- import com.greensock.TimelineMax;
- import com.greensock.plugins.*;
- import com.greensock.easing.*;
- import com.greensock.loading.*;
- import com.greensock.layout.*;
- import com.greensock.events.LoaderEvent;
- import flash.events.MouseEvent;
- import flash.events.Event;
- import flash.display.MovieClip;
- import flash.display.Stage;
- import flash.display.StageDisplayState;
- import flash.display.StageAlign;
- import flash.display.StageScaleMode;
- import index.base.func.Random;
- public class fireworks extends MovieClip {
- public var id:int;
- var tl:TimelineMax = new TimelineMax({paused: true});
- var tt:Number = 1;
- var _a:MovieClip;
- public function fireworks() {
- TweenPlugin.activate([FrameLabelPlugin, VisiblePlugin,ScalePlugin,BlurFilterPlugin]);
- _a = this.getChildByName("a") as MovieClip;
- _a.core.gotoAndStop("end");
- stage.addEventListener(MouseEvent.CLICK, clickH);
- }
- private function clickH(e:MouseEvent):void
- {
- _a.x = mouseX;
- _a.y = mouseY;
- blast();
- }
- //爆开
- function blast():void {
- TweenMax.fromTo(_a.core, .6, { frameLabel:"start" }, { frameLabel:"end" } );
- //炸开
- for (var i:int = 0; i < 30; i++)
- {
- var _b:MovieClip = new star();
- _a.addChild(_b);
- _b.rotation = Random.range(0, 360);
- TweenMax.to(_b, 0, { tint:Random.color(), scale:Random.range(.5, 2)
- , glowFilter: { color:0xffffff, blurX:18, blurY:18, strength:30, alpha:.4 }
- } );
- TweenMax.to(_b.core, .6, {scale:0.5,x:Random.range(80,260,false) } );
- TweenMax.to(_b, .6, {alpha:0,y:"50",delay:.4 } );
- }
- }
- }
- }
评论: 0 | 引用: 0 | 查看次数: 6305
发表评论