Using the hitArea : Sprite : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » Sprite »

 

Using the hitArea


 

package
{
    import flash.display.*;
    import flash.events.*;
    public class Main extends Sprite
    {
        public function Main()
        {
            var notHitArea:Sprite = new Sprite();
    
           notHitArea.graphics.beginFill(0x00FF001.0);
           notHitArea.graphics.drawRect(003030);
           notHitArea.graphics.endFill();
           addChild(notHitArea);
           notHitArea.x = 100;
           notHitArea.y = 200;
    
    
           var hitAreaSprite:Sprite = new Sprite();
           hitAreaSprite.graphics.beginFill(0x0000FF1.0);
           hitAreaSprite.graphics.drawRect(003030);
           hitAreaSprite.graphics.endFill();
           addChild(hitAreaSprite);
    
           notHitArea.hitArea = hitAreaSprite;
    
    
           hitAreaSprite.mouseEnabled = false;
    
    
           notHitArea.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler);
       }
       private function clickHandler(mouseEvent:MouseEvent):void
       {
           trace(" clickHandler ");
       }
    }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» Sprite