views:

34

answers:

2

As I can get a reference to the main window of an Air Flex application within a component? (The component is not in the main MXML)

A: 

This should do it:

var topLevelApplication : Application = Application.application as WindowedApplication

Reference: http://livedocs.adobe.com/flex/3/langref/mx/core/Application.html#application


In Flex 4, you should use the topLevelApplication property of the FlexGlobals class, something like this:

var topLevelApplication : Application = FlexGlobals.topLevelApplication as WindowedApplication
www.Flextras.com
Hi:Tanks for answer...but spark.components.Application has no application property....Im in flex 4.
caeycae
I updated my answer accordingly. In flex 4 use FlexGlobals.topLevelApplication .
www.Flextras.com
yes tanks a lot
caeycae
+1  A: 

Try FlexGlobals.topLevelApplication as WindowedApplication for flex4. Should do 'er.

jeremy.mooer
Tanks! It works!
caeycae