/**
* ...
* @author Ray Cheng
*/
[SWF(frameRate = "30", width = "800", height = "600", backgroundColor = "0x000000")]
public class BitmapEffectDemo extends Sprite
{
private var _timer:Timer;
private var _ratius:uint = 200; //--半徑
private var _circleNum:uint = 36; //--煙火數量
private var _angle:Number;
public function BitmapEffectDemo()
{
_angle = Math.PI * 2 / _circleNum;
_timer = new Timer(2000, 0);
_timer.addEventListener(TimerEvent.TIMER, onTimerCompleteHandler);
_timer.start()
}
private function onTimerCompleteHandler(e:TimerEvent):void
{
for (var i:uint = 0; i < 3; i++)
{
var $mcCircle:Shape = new Shape();
$mcCircle.graphics.beginGradientFill
(GradientType.RADIAL,
["0x" + Math.floor(Math.random() * 999999), "0x000000"],
[1, 0],
[0, 50]);
$mcCircle.graphics.drawCircle( 0, 0, 20);
$mcCircle.graphics.endFill();
$mcCircle.cacheAsBitmap = true;
$mcCircle.x = 800 / 2;
$mcCircle.y = 600 + $mcCircle.height;
addChild($mcCircle);
TweenMax.to($mcCircle, .5, { y:200 , delay:0.2 * i,
onCompleteParams:[$mcCircle], onComplete:onTweenComplete } );
}
}
private function onTweenComplete(pCircle:Shape):void
{
removeChild(pCircle)
for (var i:uint = 0; i < _circleNum; i++)
{
//trace(i)
var $circle:Shape = new Shape();
$circle.graphics.beginGradientFill(
GradientType.RADIAL,
["0x" + Math.floor(Math.random() * 999999),
"0x000000"],
[1, 0],
[0, 50]);
$circle.graphics.drawCircle(0, 0, 20);
$circle.graphics.endFill();
$circle.x = 800 / 2;
$circle.y = 200;
$circle.rotationZ = 360 / _circleNum * i;
addChild($circle)
TweenMax.to($circle, .3, { x:Math.cos(_angle * i) * _ratius + 400,
y:Math.sin(_angle * i) * _ratius + 200,
scaleX:1.5 ,
scaleY:0.5,
alpha:0 ,
onCompleteParams:[$circle],
onComplete:function(pCircle:Shape):void {
removeChild(pCircle);
}} );
}
}
2012年10月12日 星期五
Flash Native As3 基礎總整理(1-3)Bitmap與BitmapData
使用Shape()做特效..
Sprite 物件是顯示物件容器,而 Shape 物件則不是 (而且也不包含子顯示物件)。因此,Shape物件耗用的記憶體比 Sprite 物件 (都包含相同的圖像)少..
小小煙火特效demo
訂閱:
張貼留言 (Atom)

沒有留言:
張貼留言
我的留言版