Using the buttonMode of the Sprite
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var foo:Sprite = new Sprite();
foo.graphics.beginFill(0xff0000, 1);
foo.graphics.drawRect(0, 0, 100, 100);
foo.graphics.endFill();
foo.buttonMode = true;
addChild(foo);
}
}
}
Related examples in the same category