This content has been marked as final. Show 5 replies
You could create the popup object dynamically in actionscript. However, if you wanted to use mxml, I believe it has to be a separate file.
What's your reasoning for not wanting to use a separate file?
If you can use a standard class then you can pop-it up directly. I believe. I'll try this now to be sure and post an example.
Yep, you can. I'll paste an example using a Text control below. I am sure you could also pop-up a container, like a panel or HBox, and even dynamically populate it using addChild. That'll be a later example though.
Andy's question is a good one though. Except for trivial uses, an external file is much more flexible. What is you issue with an external file?
Oh, another possibility: If your application uses absolute layout, you can include some container with any content, and then set its visible property to false. To "pop it up", just make it visible. This is not really a pop-up, but looks exactly like one.
Put it at the end of the mxml, so it will display on top, or look into the depth manager.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="left">
private var _TextPopUp:Text;
private function showPopup():void
_TextPopUp = Text(PopUpManager.createPopUp(this, Text, false));
_TextPopUp.x = 100;
_TextPopUp.y = 100;
_TextPopUp.text = "Test text in pop-up"
private function closePopup():void
<mx:Button click="showPopup()" label="Pop Up Text box" />
<mx:Button click="closePopup()" label="Close Pop Up" />