Author Archives: Zevan

10,000 Transparent Sprites

CLICK HERE TO COPY
Actionscript:

stage.frameRate = 30;

 

var imageNum:int = 10000;

var point:Point = new Point(0,0);

var s:Sprite = new Sprite();

s.graphics.beginFill(0xCCCCCC);

s.graphics.lineStyle(0,0x000000);

s.graphics.drawCircle(3,3,3);

s.alpha = .1;

 

var nested:Sprite = new Sprite();

nested.addChild(s);

var image:BitmapData = new BitmapData(s.width, s.height, true, 0x00000000);

image.draw(nested);

 

var canvas:BitmapData = new BitmapData(400,400, true, 0xFFFFFFFF);

addChild(new Bitmap(canvas));

 

var xPos:Array = new Array();

var yPos:Array = new Array();

for (var i:int = 0; i<imageNum; i++) {

    xPos.push(Math.random()*400);

    [...]

Posted in BitmapData, motion | Tagged , , | 2 Comments

Loader, Centering, Smoothing

CLICK HERE TO COPY
Actionscript:

var image:Loader = new Loader();

image.load(new URLRequest("http://www.shapevent.com/sketchbook/wp-content/uploads/avalanche.jpg"));

image.x = stage.stageWidth / 2;

image.y = stage.stageHeight / 2;

addChild(image);

 

image.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

function onComplete(evt:Event):void {

   

    // CENTER THE IMAGE

    image.content.x = -image.content.width / 2;

    image.content.y = -image.content.height / 2;

   

    // BITMAP SMOOTHING

    Bitmap(image.content).smoothing = true;

    image.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);

}

 

 

// scale the image [...]

Posted in Uncategorized | 3 Comments

Reset Registration Point

CLICK HERE TO COPY
Actionscript:

// display object target, value - "center" or "upperLeft"

function setRegistration(dsp:DisplayObjectContainer, v:String):void {

    var i:int;

    var child:DisplayObject;

    var b:Rectangle=getBounds(dsp);

    for (i = 0; i <dsp.numChildren; i++) {

        child=dsp.getChildAt(i);

        child.x+=b.x*-1;

        child.y+=b.y*-1;

    }

    if (v=="center") {

        dsp.x+=dsp.width/2;

  [...]

Posted in DisplayObject, display list | Tagged , , | 2 Comments

Skew DisplayObject

CLICK HERE TO COPY
Actionscript:

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

with (box.graphics) beginFill(0x006666), drawRect(0,0,50,50);

box.x = box.y = 100;

 

addEventListener(Event.ENTER_FRAME, onLoop);

 

function onLoop(evt:Event):void {

   

    var m:Matrix = box.transform.matrix;

    // skew on the X

    m.c = (mouseX - stage.stageWidth / 2 ) / stage.stageWidth;

   

    // skew on the Y

    // m.b = (mouseX [...]

Posted in DisplayObject, motion | Tagged , , | Leave a comment