Yes, a CustomWindow.mxml is the answer.
1 person found this helpful
I'm assuming you want to actuallydisplay the new window in a PopUp rather than as a subcomponent of Main.mxml right? In that case what you would do is add an event listener to your list that calls a method in Main.as when an item in the list is double clicked. You would pass whatever data the new window needs to have about the selected item along as parameters of the handler method. Inside the handler method you would then do the following,
1. Create a new instance of your custom window.
2. Set the fields of the custom window component to the values passed into the handler method as parameters.
3. Once all the properties of the window are initialized, add it to the display by calling PopUpManager.addPopUp().
So in Main.as you would have something like this:
//Not sure how the compiler would deal with two classes named Main in the same
//package so give the controller a different name to be safe.
public class MainCtl
//need to keep a class level reference to the window instance to use in the close handler
private var myWindow:MyWindow;
public function displayMyWindow( arg1:String, arg2:Number ):void
myWindow = new MyWindow();
myWindow.bookName = arg1;
myWindow.bookPrice = arg2;
//Instead of topLevelApplication, you could also pass in a reference to Main.mxml to use as the parent.
PopUpManager.displayPopUp( myWindow, FlexGlobals.topLevelApplication as DisplayObject, true);
public function closeMyWindow()
Wow, Thanks for your generosity.
A popup.... I think so. It gets confusing because there are references to custom window components and references to popup windows. Are they one-in-the-same?
I have a list of authors and if I doubleClick an author in it I am doing so because I want to review/edit information in another window. It is for temporary use.
I hope I'm not getting confused with modal windows here. Those are just for messages to the user if I'm not mistaken.
I've read stuff about value objects, forms, binding data and classes. ("Oh my!")
So far all my code is in a single actionscript file. I haven't ventured into classes yet. I know I'm going to have to someday.
1 person found this helpful
When they are refering to custom window components, what they mean is the actual mxml or actionscript class you use to display your information. If they are talking about a pop-up window it simply means you are using the PopUpManager to display the window rather than displaying it as a subcomponent in another component. As for modal windows, any window displayed with the PopUpManager can be modal, it simply means that the user can't interact with other components outside the window ( for example the list of authors) while the pop-up is displayed. If you notice in my example, PopUpManager.addPopUp() has 3 arguments. The first two are the component to display and it's parent. The third argument is a boolean indicating wehther or not the window should be modal.
If you want a window that just displays some text to the user, such as a confimation dialog then use the Alert class. It's similar to a pop-up but rather than defining a custom window class you just pass in the text you wnat to display when you call Alert.show and it takes care of the rest.
Thank you again.
I'm looking through my Flex bible and they talk about TitleWindow. I looked at a Lynda video where they created a spark.component.window.
The Adobe livedocs has yet another implementation where the ApplicationWindow acts as a splash screen and then a window container is the application window, which kind of implies a different use of the spark.component.window.
Honestly I don't know which route to take.
Suppose you have an author in your list and you realize you misspelled the name. Or you want to add some other detail in the future.
This is my objective. Is that a TitleWindow or the other?
Again, thank you very much. If I'm being dense I apologize.
I think the instance I tried was a subcomponent of the main window because I did not use the PopUpManager. It worked yesterday, but today when I tried to run it there were errors so I ended up deleting the code. Sort of been frustrated with the IDE.
And, sorry. Something else because I keep reading.
TitleWindow, I read, can have a close button. Is that all? Because I need to commit data to a sqlite database. Is that sufficient?
From what I read it does sound like you should use the titlewindow. You can use it as the base for your component and build your component within. Just like what was said previously, you will need to use the PopUpManager to display it. The TitleWindow is just like a panel with a close button in the upper right corner of the border. If you need other buttons, such as a save button, you can add it to the TitleWindow.
Great. Thank you very much. I get it now.
And thanks to all who replied.
I really appreciate being pointed in the right direction.