0

I want to use Object Handler for Sprite but any of the Handler not working for Sprite Please any one suggest me how can i Handle Sprite Component with Object Handler

  <s:Application name="Spark_SpriteVisualElement_addChild_test"
           xmlns:fx="http://ns.adobe.com/mxml/2009"
           xmlns:s="library://ns.adobe.com/flex/spark"
           xmlns:mx="library://ns.adobe.com/flex/mx"
           initialize="init();">
<fx:Script>
    <![CDATA[

        import mx.core.UIComponent;
        private const spr1:Sprite = new Sprite();

        private var bmd:BitmapData;// = new BitmapData();
        private function init():void {
            spr1.graphics.beginFill(0xFF0000, 0.5);
            spr1.graphics.drawRect(10, 10, 100, 80);
            spr1.graphics.endFill();
            spr.addChild(spr1);
        }           
    ]]>
</fx:Script>
<s:SpriteVisualElement id="spr" />

Manan
  • 257
  • 1
  • 10

2 Answers2

0

Check out Object Handles.

What is it?
Actionscript 3 Library to enable user movement & resizing of components.

Marty
  • 39,033
  • 19
  • 93
  • 162
ashoo_bob
  • 162
  • 3
0

Below code may help you: -

private function init():void
{
    spr1.graphics.beginFill(0xFF0000, 0.5);
    spr1.graphics.drawRect(10, 10, 100, 80);
    spr1.graphics.endFill();
    spr.addChild(spr1);
    spr1.addEventListener(MouseEvent.CLICK, onClickHandler);
} 

private function onClickHandler(event:MouseEvent):void
{
    trace("Click Perform")
}
Marty
  • 39,033
  • 19
  • 93
  • 162
Mahesh Parate
  • 786
  • 1
  • 4
  • 13