7 Replies Latest reply on Apr 22, 2011 8:25 PM by Kristin95762

    My TitleWindow is set up, now I need to pass some data

    Kristin95762 Level 1

      This is Flash Builder I'm talkin' about.

       

      Having a really hard time finding examples on this subject.

       

      My main app contains a list box with authors.

       

      When I double click on an author, the TitleWindow popup appears. That part is great thanks to some wonderful help here on the forum.

       

      Now, how do I transfer the author name to the popup, and then transfer any changes I make back to the list?

       

      There was one method I saw (very limited info on it) which indicated that I could access the children of the popup from the main application, which I think would be ideal in my case because I'm a noob trying to set up a local database application (sqlite), and all these components and classes are giving me a headache.

       

      My popup merely contains a label, a text input, and a button. In the future I might like to add a datagrid but I'm having trouble figuring out the theory of the popup and data transfer.

       

      Thank you much

       

      Kristin

        • 1. Re: My TitleWindow is set up, now I need to pass some data
          jfb00 Level 3

          Hi,

          Are you calling the popup window like this?

           

           

          customWin=myScreen(PopUpManager.createPopUp(this.parentDocument as DisplayObject,myScreen,true));
          customWin.mainApp = this;
          customWin.title = "My title";
          PopUpManager.centerPopUp(customWin);
          

           

          Where mainApp variable contain the parent info, so in the custom window you need to declare a variable like:

          [Bindable] public  var mainApp:Object = null;
          

           

          Then you have access to the label from the parent window like:

          var temp:String = "";
          temp = mainApp.myLabel.text;
          

           

          You also can call a function from the parent windows but make sure the function is declare as private.

          I hope this help.

          Rgds

           

          Johnny

          1 person found this helpful
          • 2. Re: My TitleWindow is set up, now I need to pass some data
            brendalc1636

            I usually end up displaying my titlewindow from some actionscript code. Usually I read in some data, then display the title window. Since I am doing it from the actionscript code, and not from the display, I create an instance of my TitleWindow and send that to the popup manager. I can then set variables on the instance to whatever values I wish.

             

            var myTitleWindow:TitleWindow = new MyTitleWindow();

            myTitleWindow.myLabel.text = "Label Text";

            myTitleWindow.myButton.text = "Button Text";

            PopUpManager.addPopUp(myTitleWindow, DisplayObject(Application.application), false);

            PopUpManager.centerPopUp(myTitleWindow);

             

            Brenda

            • 3. Re: My TitleWindow is set up, now I need to pass some data
              Kristin95762 Level 1

              Hi,

               

              All my code is in an actionscript file and this is the function I use:

               

               

              private function authorsList_doubleClickHandler(event:MouseEvent):void

              {

              PopUpManager.createPopUp(this, authorEdit, true);

              }

               

              This is the code in the TitleWindow component mxml file:

               

              <fx:Script>

              <![CDATA[

              import mx.events.*;

              import mx.managers.PopUpManager;

               

              private function titlewindow1_closeHandler(event:CloseEvent):void

              {

              PopUpManager.removePopUp(this);

              }

               

              private function submitHandler(event:MouseEvent):void

              {

              if((authorName.text = "Hello"))

              {

              PopUpManager.removePopUp(this);

              }

              }

               

              ]]>

              </fx:Script>

               

              I think there is some way to access the textarea and the submit button from the main application file. Just haven't figured out how to do it.

              • 4. Re: My TitleWindow is set up, now I need to pass some data
                Kristin95762 Level 1

                Hi

                 

                So, all the code you listed in your reply is in the main application file, correct?

                • 5. Re: My TitleWindow is set up, now I need to pass some data
                  Kristin95762 Level 1

                  In your code copied below:

                   

                  PopUpManager.addPopUp(myTitleWindow, DisplayObject(Application.application), false);

                   

                  What does (Application.application) stand for?

                   

                  Thank you

                   

                  Kristin

                  • 6. Re: My TitleWindow is set up, now I need to pass some data
                    Flex harUI Adobe Employee

                    Application.application in Flex 3 is FlexGlobals.topLevelApplication in Flex

                    4.

                     

                    FWIW, my recommendation is that the TitleWindow components should pull their

                    data from a central data model.  Model-View or MVC architectures are a bit

                    more to set up, but pay off in the end.

                     

                    -Alex

                    • 7. Re: My TitleWindow is set up, now I need to pass some data
                      Kristin95762 Level 1

                      Okay, thanks for your advice. I see where I have to start looking.

                       

                      As a neophite in Flex 4, and not all that well versed in AS3 I've been trying to keep things as simple as possible while learning how to code. I figured once I got everything working well enough I'd turn to figuring out how to do it right.

                       

                      Hey, if you know a lot about AIR, how about writing a new book. Information is so hard to find on that subject.

                       

                      Thanks again Alex.

                       

                      Kristin