3 Replies Latest reply on Nov 29, 2013 2:57 AM by pauland

    Passing vars to a component in as3

    home_aidan Level 1

      This doesnt seem particulary easy... or poetic for once of a better word.

       

       

      I was hoping I could write something like....

       

      BookingCreator = new CreateBooking(myvar);

       

      But what do I put In the mxml constructor for that component?

       

      Its a panel so where does myvar go?

       

      If I could hand it myvar like that I would then use creationComplete.

      But because I dont no how to pass a var direct to the constructor Im doing it this way instead...

       

       

       




      BookingCreator = new CreateBooking();



      BookingCreator.addEventListener(FlexEvent.CREATION_COMPLETE,onCreated);



      mod.root.addElement(BookingCreator);

       

       

       



      private function onCreated(e:FlexEvent):void{


      BookingCreator.model = mod;


      BookingCreator.init();







      }

       

       

      Is that the only way to do it?