forked from: flash on 2011-7-4
/**
* Copyright tiborstuchlik ( http://wonderfl.net/user/tiborstuchlik )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/lihf
*/
// forked from oddeye's flash on 2011-7-4
package {
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.text.TextField;
import flash.geom.Point;
import flash.filters.BlurFilter;
import com.greensock.TweenMax;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
init();
}
private function init():void
{
var txt:TextField=TextBuild.to( new TextField(), "Píča");
//addChild(txt);
var bmd:BitmapData=new BitmapData( txt.width, txt.height, false, 0x00CC00);
bmd.draw( txt );
bmd.applyFilter( bmd, bmd.rect, new Point(0,0), new BlurFilter() );
bmd.draw( txt );
splitMotion( bmd );
}
private function splitMotion(bmd:BitmapData):void
{
for(var i:int=0;i< bmd.width ;i++)
{
for(var j:int=0;j<bmd.height ; j++)
{
TweenMax.to( randomPos( addChild( new Circle( bmd.getPixel(i, j),6)) ),
0.5, { x:i*12, y:j*12, alpha:1, delay:(i+j)*0.05*Math.random() } );
}
}
}
private function randomPos( target:DisplayObject ):DisplayObject
{
target.x=Math.random()*465;
target.y=Math.random()*465;
target.alpha=0;
return target;
}
}
}
import flash.display.Sprite;
import flash.text.TextFormat;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
class TextBuild
{
public static function to(tld:TextField, str:String,
size:int=11, color:uint=0x000000, fontName:String="Verdana"):TextField
{
var tmf:TextFormat=new TextFormat();
tmf.size=size;
tmf.color=color;
tmf.font=fontName;
tld.autoSize=TextFieldAutoSize.LEFT;
tld.defaultTextFormat=tmf;
tld.text=str;
return tld;
}
}
class Circle extends Sprite
{
public function Circle( color:uint, radius:Number=5)
{
this.graphics.beginFill( color );
this.graphics.drawCircle(0,0, radius);
this.graphics.endFill();
}
}