Wednesday, April 8, 2009

A little confused. I'd like to be able to "draw something" and then have it be interactive: dragable, clickable, whatever. Here's the code I have, but I cannot drag the movie clip:
var a:MovieClip = new MovieClip();
var child:Shape = new Shape();
child.graphics.beginFill(0xFF0000);
child.graphics.drawRect(0, 0, 100, 100);
child.graphics.endFill();
a.addChild(child);
this.addChild(a);
a.x=100;
a.y=100;
a.addEventListener(MouseEvent.MOUSE_DOWN,keyPressHandler);
a.addEventListener(MouseEvent.MOUSE_DOWN,keyReleaseHandler);
function keyPressHandler(event:MouseEvent):void
{
a.startDrag();

}
function keyReleaseHandler(event:MouseEvent):void
{
a.stopDrag();
}

0 comments: