flash on 2012-2-22
♥0 |
Line 52 |
Modified 2012-03-29 21:21:07 |
MIT License
archived:2017-03-30 09:22:43
ActionScript3 source code
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/9KRZ
*/
package
{
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.filters.*;
import flash.geom.*;
[SWF(width=500,height=500,backgroundColor=0xffffff,frameRate=24)]
public class shock extends Sprite
{
public function shock():void
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var trail:Bitmap = new Bitmap(new BitmapData(500, 500, false, 0));
trail.filters = [new BlurFilter( 6,6,3 ) ];
addChild(trail);
var ovals:Array = new Array(101);
var color:uint = 0xffffff * Math.random();
for (var t:int = 0; t < 101; t++)
{
ovals[t] = new Sprite();
var p:TextField = new TextField();
ovals[t].addChild(p);
addChild(ovals[t]);
}
ovals[0].y = -2 * t * Math.sin(mouseY / 200 - 0.5) + 250;
var cnt:int = 0;
addEventListener(Event.ENTER_FRAME, function(event:Event):void
{
cnt++;
trail.bitmapData.draw(stage);
for (var t:Number = 1; t < 101; t++)
{
ovals[t].getChildAt(0).x = Math.sin(t / (5000) * Math.PI * cnt) * t * 2;
ovals[t].getChildAt(0).y = Math.cos(t / (5000) * Math.PI * cnt) * t * 2;
ovals[t].getChildAt(0).text = "•"; //Math.round(Math.random());
ovals[t].getChildAt(0).textColor = color;
ovals[t].x += (ovals[t - 1].x - ovals[t].x) * 0.65;
ovals[t].scaleY = Math.cos(mouseY / 200 - 0.5);
ovals[t].y = -2 * t * Math.sin(mouseY / 200 - 0.5) + 250;
}
ovals[0].x = mouseX;
if ((cnt) % 50 == 0)
{
color = Math.random() * 0xffffff;
}
});
} //end of function
} //end of class
} //end of package