/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/xRwC
*/
package
{
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.*;
import flash.display.BitmapData;
import flash.events.*;
import flash.text.*;
import flash.geom.*;
import flash.filters.*;
import com.greensock.TweenMax;
import com.greensock.easing.*;
public class Main extends Sprite
{
private var str:String="BradSedito";
private var arrayList:Array=[];
private var contain:Sprite=new Sprite();
private var key:Boolean=false;
public function Main()
{
init();
}
private function init():void
{
addChild(contain);
contain.y=100;
var txt:TextField=new TextField();
txt.defaultTextFormat=new TextFormat("Arial",25,0xffff00);
txt.autoSize=TextFieldAutoSize.LEFT;
txt.text=str;
addChild(txt);
txt.x=10;
txt.y=10;
var bmpdata:BitmapData=new BitmapData(txt.width,txt.height,false,0x0);
bmpdata.draw(txt);
for (var i:int=0; i<bmpdata.width; i++)
{
for (var j:int=0; j<bmpdata.height; j++)
{
var color:uint=bmpdata.getPixel(i,j);
var red:uint=(color>>16 )&0xff;
if (red>0)
{
var px:Number=j*5;
var py:Number=i*5;
var qq:QQ=new QQ();
qq.x=Math.random()*550;
qq.y=Math.random()*400;
qq.filters=[new GlowFilter(),new BlurFilter(1,1,3)];
var p:Particle=new Particle();
p.x=px;
p.y=py;
p.obj=qq;
contain.addChild(qq);
arrayList.push(p);
}
}
}
render();
stage.addEventListener(MouseEvent.CLICK,onClickHandler);
}
private function render( ):void
{
for (var i:int=0; i<arrayList.length; i++)
{
TweenMax.to(arrayList[i].obj,Math.random()*2+1,{x:arrayList[i].y,y:arrayList[i].x});
}
}
private function randomMove():void
{
for (var i:int=0; i<arrayList.length; i++)
{
TweenMax.to(arrayList[i].obj,Math.random()*2+1,{x:Math.random()*550,y:Math.random()*400});
}
}
private function onClickHandler(event:MouseEvent):void
{
if (!key)
{
key=true;
randomMove();
}
else
{
key=false;
render();
}
}
}
}
internal class Particle
{
public var x:Number;
public var y:Number;
public var radius:Number=0;
public var color:uint;
public var obj:*;
public var angle:Number;
public function Particle()
{
}
}
import flash.display.Sprite;
import flash.text.*;
internal class QQ extends Sprite
{
public function QQ()
{
var txt:TextField=new TextField();
txt.defaultTextFormat=new TextFormat("Arial",10,0xffff00);
txt.autoSize=TextFieldAutoSize.LEFT;
txt.text="QQ";
txt.x=-txt.width/2;
txt.y=-txt.height/2;
txt.selectable=false;
addChild(txt);
}
public function move(x:Number,y:Number):void
{
this.x=x;
this.y=y;
}
}