Flex: Accessing the stage

Submitted by:Pitter Alderson

Date added:29 June, 2011

Category:MXML

There are times when you need to access the stage property before onCreationComplete. Here are two ways to do it.

Tags: flex

Code Snippet:

/***********************
Method 1: On Added handler
***********************/
addEventListener( Event.ADDED_TO_STAGE, function( e:Event ):void
{
stage.addEventListener( MouseEvent.MOUSE_MOVE, myMouseMoveEvent );
});

/***********************
Method 2: The system manager parents all displayable elements within the Flex application.
***********************/
systemManager.stage.addEventListener( MouseEvent.MOUSE_MOVE, myMouseMoveEvent );
 
 

Comments