Local Global Sample : stage « Development « Flash / Flex / ActionScript






Local Global Sample

 
package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    public class Main extends Sprite
    {
        public function Main()
        {

            this.stage.scaleMode = "noScale";
            this.stage.align = "tl";

            var localSprite:Sprite = new Sprite();
            localSprite.graphics.beginFill(0x00ffCC, 1);
            localSprite.graphics.drawCircle(0, 0, 50);

            localSprite.graphics.endFill();

            addChild(localSprite);
            localSprite.x = 200;
            localSprite.y = 200;

            localSprite.addEventListener(MouseEvent.MOUSE_MOVE, moving);
        }

        private function moving(mouseEvent:MouseEvent):void
        {
            trace(' local ' + mouseEvent.localX + ' ' + mouseEvent.localY);
            trace(' stage ' + mouseEvent.stageX + ' ' + mouseEvent.stageY);
        }
    }
}

        








Related examples in the same category

1.Setting the Frame Rate
2.Traversing Objects in a Display Hierarchy
3.Recursive display list tree traversal
4.Distinguishing Events Targeted at an Object from Events Targeted at That Object's Descendants
5.responds to mouse clicks that occur over any object on the display list, but not over a vacant area of the Stage instance
6.A stretchy layout
7.Simple Scribble
8.Working with the Stage