Reputation: 4627
I'm using Flex 4.5, and I have imported a custom class I wrote into the main MXML file.
Inside the class file, I want to be able to create a TitleWindow
using the PopUpManager
like this:
package classes {
import components.*; // My custom components
import mx.managers.PopUpManager;
public class SomeClass {
public function showPopUp():void {
PopUpManager.createPopUp(this,NewProjectPrompt,true);
}
}
}
NewProjectPrompt
is a custom component I made. The compiler is giving me the following error:
1067: Implicit coercion of a value of type classes:Project to an unrelated type flash.display:DisplayObject.
This is because this
isn't pointing at WindowedApplication
. How do I make the first parameter in .createPopUp()
point to the WindowedApplication
?
Upvotes: 1
Views: 291
Reputation: 328
If your WindowedApplication file is named "MyApp.mxml" then you would write a reference from a component to it like this:
MyApp(this.parentApplication)
This will return the actual WindowedApplication and you can call its public methods or stick it in a variable if need be.
Upvotes: 1
Reputation: 241
this code works!
public function showPopUp(){
PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject,NewProjectPrompt,true);
}
Upvotes: 2