PDA

View Full Version : The 'stage' keyword


Chuck Taylor
03-17-2007, 12:54 PM
I thought 'stage' was a top level global variable. Apparently it isn't so. Even importing 'flash.display.Stage' doesn't help. How to refer to the stage object?

I have seen 'stage' being used in some of senocular's tutorials too. Eg:

stage.addEventListener(MouseEvent.MOUSE_UP, captureMouseUp);

Paul Ferrie
03-17-2007, 01:01 PM
have u tried Stage

Chuck Taylor
03-17-2007, 01:15 PM
Yea, it doesn't work either.

Paul Ferrie
03-17-2007, 01:19 PM
Am at a loss and out of ideas:eek:

cybergatuno
03-17-2007, 05:28 PM
stage is no keyword, it's an attribute of all instances of DisplayObject and subclasses. When you write "stage.addEvent..." you're actually writing "this.stage.addEvent...". Again, it's only available in instances of DisplayObject.

Chuck Taylor
03-17-2007, 06:38 PM
Thanks a lot man. I get it now.

Tink
03-17-2007, 08:51 PM
the property is only available when your DisplayObject is actually in a display list. if its not in a display list it will return null.

senocular
03-18-2007, 08:10 PM
There should be a section in the tip of the day tips that cover that.