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);
}
}
}
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 :
I’m not 100% sure about why FlexGlobals.topLevelApplication does not return a DisplayObject, might be a low-level issue.