Test
test
/**
* Copyright ShipNK ( http://wonderfl.net/user/ShipNK )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zFdr
*/
package {
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event
import flash.events.MouseEvent;
public class FlashTest extends Sprite {
private var i:int;
public var shape:Shape = new Shape;
public var arr:Array = new Array;
public function FlashTest() {
stage.addEventListener( Event.ENTER_FRAME, process );
stage.addEventListener( MouseEvent.CLICK, clickEvent );
}
public function clickEvent ( e:MouseEvent ) :void
{
for( i = 0; i < 100; ++ i )
{
shape = new Shape();
shape.graphics.beginFill( int( Math.random() * Math.pow( 16, 6 ) ) );
shape.graphics.drawCircle( 0, 0, Math.random() * 5 );
addChild( shape );
shape.x = mouseX + Math.random() * 401 - 200;
shape.y = mouseY + Math.random() * 401 - 200;
arr.push( shape );
}
}
public function process ( e:Event ) :void
{
shape = new Shape();
shape.graphics.beginFill( int( Math.random() * Math.pow( 16, 6 ) ) );
shape.graphics.drawCircle( 0, 0, Math.random() * 30 );
addChild( shape );
shape.x = mouseX + Math.random() * 71 - 35;
shape.y = mouseY + Math.random() * 71 - 35;
arr.push( shape );
//
for( i = arr.length -1; i > -1; -- i )
{
shape = arr[ i ] as Shape;
shape.x -= (mouseX - 275) / 30;
shape.y -= (mouseY - 200) / 30;
shape.alpha *= 0.9;
if( shape.alpha < 0.05 )
{
removeChild( shape );
arr.splice( i, 1 );
}
}
}
}
}