Monday, April 6, 2009

Drawing and Manipulating in Flash

I found out how to "draw something" in Flash and then be able to move it around using event listeners.
var a:Sprite = new Sprite();
a.graphics.beginFill(0xFF00FF);
a.graphics.drawRect(200,0,100,100);
a.graphics.endFill();
a.addEventListener(MouseEvent.MOUSE_DOWN, mousedown);
a.addEventListener(MouseEvent.MOUSE_UP, mouseup);
addChild(a);

function mousedown(event:MouseEvent):void
{
this.startDrag();
}

function mouseup(event:MouseEvent):void
{
this.stopDrag();
}

Now my task is to generate a whole bunch of sprites (or shapes) and be able to individually move around each one.

0 comments: