3 Replies Latest reply on Sep 27, 2011 5:11 AM by daslicht

    Passing variables from between popups




      I have a main app which creates a popup using myRoomForm.mxml:


      private function popUpRoomForm(xmlValuesList:XMLList):myRoomForm {


                   var frmRoom:myRoomForm=myRoomForm(PopUpManager.createPopUp(this,myRoomForm,true));




                   return frmRoom;



      Then from inside the room form (myRoomForm.mxml), depending on the situation I need to create a subform (mySubRoomForm.mxml). Again I'm using:



      private function popUpSubRoomForm(xmlValuesList:XMLList):mySubRoomForm {


                     var frmSubRoom:mySubRoomForm = mySubRoomForm(PopUpManager.createPopUp(this,mySubRoomForm,true));




                     return frmSubRoom;




      I have tried bubbling events dispatching them from the sub room, but my listener on the room form wouldn't pick them up.

      I then tried using a global actionscript file and setting the variables from the sub room and once the sub room form closed, I tried to get them from the room form. This didn't work because my room didn't know when the sub room form closed.

      The I tried creating static public variables directly on the room and setting them from the sub room, but the new() instance of room wouldn't let me create static public variables and if it did I couldn't reference them from the sub room anyway.


      All I need is a way to send text from a few text fields on sub room so that when the sub room form is closed the corresponding text fields on the room form are updated.


      Ideally I'd like to get the custom event handler working, but I've taken too long on this and just need an immediate solution.


      Any help would be greatly appreciated.


      Here is my attempted event handler:


      Sent from the subroom:


      SubRoomData.addItem("TEST SUB ROOM DATA");


                                              var newSubRoomEvent:SubRoomEvent = new SubRoomEvent("newSubRoomEvent");

                                              newSubRoomEvent.sendSubRoomData = SubRoomData;




      Referencing this .as

      package utils


                import flash.events.Event;

                import mx.collections.ArrayCollection;


                public class SubRoomEvent extends Event


                          public var sendSubRoomData:ArrayCollection;


                          public function SubRoomEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false)


                                    super(type, bubbles, cancelable);





      And my listener on the room form (which I've tried creating both inside myRoomForm.mxml and inside MainApp.mxml when creating the popup without any joy):

      frmRoom.addEventListener(SubRoomEvent.newSubRoomEvent, frmRoom.processSubRoomEvent);