Author Archives: Zevan

Cut Image into Squares (copyPixels)

CLICK HERE TO COPY
Actionscript:

[SWF(width=650, height=650)]

var loader:Loader = new Loader();

loader.load(new URLRequest("http://actionsnippet.com/wp-content/chair.jpg"));

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);

 

var w:Number;

var h:Number;

var rows:Number = 20;

var cols:Number = 20;

var tiles:Vector.<BitmapData> = new Vector.<BitmapData>();

var locX:Vector.<Number> = new Vector.<Number>();

var locY:Vector.<Number> = new Vector.<Number>();

var rX:Vector.<Number> = new Vector.<Number>();

var rY:Vector.<Number> = new Vector.<Number>();

var sX:Vector.<Number> = new Vector.<Number>();

var sY:Vector.<Number> = new Vector.<Number>();

function onLoaded(evt:Event):void{

    w = evt.target.width;

    h = [...]

Posted in BitmapData, Vector | Tagged , , | 10 Comments

Cut Image Into Squares

CLICK HERE TO COPY
Actionscript:

[SWF(width=650, height=650)]

var loader:Loader = new Loader();

loader.load(new URLRequest("http://actionsnippet.com/wp-content/chair.jpg"));

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);

x = y = 25;

var w:Number;

var h:Number;

var rows:Number = 20;

var cols:Number = 20;

var tiles:Vector.<Sprite> = new Vector.<Sprite>();

function onLoaded(evt:Event):void{

    w = evt.target.width;

    h = evt.target.height;

    var image:BitmapData = Bitmap(evt.target.content).bitmapData;

    var tileWidth:Number = w / cols;

    var tileHeight:Number = h / rows;

  [...]

Posted in BitmapData, external data | Tagged , , , | 12 Comments

BitmapData & Particles

CLICK HERE TO COPY
Actionscript:

stage.frameRate = 30;

stage.quality = StageQuality.LOW;

 

var canvas:BitmapData = new BitmapData(400,400,false, 0x000000);

addChild(new Bitmap(canvas));

var overlay:BitmapData = new BitmapData(400,400,true, 0x12000000);

var particles:Dictionary = new Dictionary(true);

 

var blur:Array = [new BlurFilter(8,8,1)];

   

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {

    for (var i:int= 0; i<3; i++) createParticle();

    canvas.copyPixels(overlay, canvas.rect, new Point(0,0), null, null, true);

}

 

function createParticle():void{

    var s:MovieClip = new MovieClip();

  [...]

Posted in BitmapData, Graphics, motion | Tagged , , | Leave a comment

drawTriangles() 2D Textured Plane

CLICK HERE TO COPY
Actionscript:

[SWF(width = 700, height = 700)]

 

var loader:Loader = new Loader();

loader.load(new URLRequest("http://actionsnippet.com/wp-content/chair.jpg"));

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);

var tex:BitmapData;

function onLoaded(evt:Event):void{

    tex = Bitmap(loader.content).bitmapData;

    addEventListener(Event.ENTER_FRAME, onLoop);

}

 

var plane:Shape = Shape(addChild(new Shape()));

plane.x = plane.y = 50;

 

var verts:Vector.<Number> = new Vector.<Number>();

var uvs:Vector.<Number> = new Vector.<Number>();

var indices:Vector.<int> = new Vector.<int>();

var rows:int = 30;

var size:Number = rows + 1;

var vertNum:Number = size [...]

Posted in BitmapData, Graphics, Vector | Tagged , , | 2 Comments