9 Replies Latest reply on Apr 21, 2011 3:59 PM by Kristin95762

    Where to go after I create a spark.component.window

    Kristin95762 Level 1

      I'm new to Flash Builder and have a little experience with AS3.


      I've been looking through a lot of tutorials and all of them are pretty much the same when it comes to showing how to create a custom window component. After that the silence is deafening.


      Could you please point me in the right direction as to how to actually code the window functionality?


      I have a main window with a list box on it. When I doubleClick an item in the list I open up a new window. This app is a sqlite app. I want to add/edit items in the new window. I'm stuck about how to port the selected item data from my main window to the new window and add new stuff to my database.


      Currently I have my ActionScript in a separate file (Main.mxml, Main.as). Would I handle this similary with my custom window, such as customWindow.mxml and customWindow.as?


      Maybe this requires a custom class and in that case I'm stumped.





        • 1. Re: Where to go after I create a spark.component.window
          Flex harUI Adobe Employee

          Yes, a CustomWindow.mxml is the answer.

          • 2. Re: Where to go after I create a spark.component.window
            bucpatr1 Level 2

            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()


                      PopUpManager.removePopUp( myWindow);




            1 person found this helpful
            • 3. Re: Where to go after I create a spark.component.window
              Kristin95762 Level 1

              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.



              • 4. Re: Where to go after I create a spark.component.window
                bucpatr1 Level 2

                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.

                1 person found this helpful
                • 5. Re: Where to go after I create a spark.component.window
                  Kristin95762 Level 1

                  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.

                  • 6. Re: Where to go after I create a spark.component.window
                    Kristin95762 Level 1

                    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.

                    • 7. Re: Where to go after I create a spark.component.window
                      Kristin95762 Level 1

                      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?

                      • 8. Re: Where to go after I create a spark.component.window
                        brendalc1636 Level 1

                        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.



                        • 9. Re: Where to go after I create a spark.component.window
                          Kristin95762 Level 1

                          Great. Thank you very much. I get it now.


                          And thanks to all who replied.


                          I really appreciate being pointed in the right direction.