0
votes

I have an AS3 class on my Flex project:

package system
{
    import mx.managers.PopUpManager;

    import ui.Eula;

    public class Dialogs
    {
        public function Dialogs(){}

        public static function showEula():void {
            var eulaWindow:Eula = new Eula;
            PopUpManager.addPopUp(eulaWindow,MyMainMXML,true);
        }
    }
}

MyMainMXML is my base MXML file. It won't let me reference to it via my class. How do I do that? The compiler error goes as follows:

1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.

The main MXML file is a spark WindowedApplication so I assumed it's part of the DisplayObjects.

EDIT:

I tried using FlexGlobals like the one below but it gives off an error that says 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.

package system
{
    import mx.core.FlexGlobals;
    import mx.managers.PopUpManager;

    import ui.Eula;

    public class Dialogs
    {
        public function Dialogs(){}

        public static function showEula():void {
            var eulaWindow:Eula = new Eula;
            PopUpManager.addPopUp(eulaWindow,FlexGlobals.topLevelApplication,true);
        }
    }
}
2
Use Flexglobals.topLevelApplication - RIAstar

2 Answers

1
votes

Using FlexGlobals.topLevelApplication returns you an object of type Object (yeah I know, that sounds redoundant :P). However addPopUp 2nd parameter if a DisplayObject. Hence, this should do the trick :

PopUpManager.addPopUp(eulaWindow,FlexGlobals.topLevelApplication as DisplayObject,true);

I'm not 100% sure about why FlexGlobals.topLevelApplication does not return a DisplayObject, might be a low-level issue.

1
votes

You can got main application refference from

FlexGlobals.topLevelApplication

mx.core.FlexGlobals.topLevelApplication: The top-level application object, regardless of where in the document tree your object executes. This object is of type spark.components.Application or mx.core.Application.