4 Replies Latest reply on Feb 16, 2010 8:50 AM by msakrejda

    Instantiate a new MXML object...pass arguments into it?

    Cinema4

      Hello,

       

      In my Flex app I am dynamically creating some Tabs to my tabNavigator, which loads some MXML component with some text labels etc.

       

       

      Heres a snippet of the code in question:

       

      private function addChildToTabAtIndex(childType:int,index:int):void{

       

      var childToAdd:Object;

       

      switch(childType){

       

                               case 0 : childToAdd = new Page1(); //Page1 is an MXML component

                               break;

           }

      }

      myTab.addChildAt(childToAdd as DisplayObject,index);

      }

       

       

      What I would like to do is pass some 'constructor' info into this new page/component

      ie:

       

      case 0 : childToAdd = new Page1(myVar1, myVar2, etc... );

       

       

      Can I pass some variable information this way...or does there need to be some intermediary AS file that I would pass info into, and the new MXML file loads that...etc...etc..

       

      Thanks in advance for any help or suggestions.

       

      ....

      ....

       

      What I would like to do is pass some 'constructor' info into this new page/component

      ie:

       

      case 0 : childToAdd = new Page1(myVar1, myVar2, etc... );

       

       

      Can I pass some variable information this way...or does there need to be some intermediary AS file that I would pass info into, and the new MXML file loads that...etc...etc..

       

      Thanks in advance for any help or suggestions.