1 Reply Latest reply on Mar 16, 2009 6:24 AM by Newsgroup_User

    Loading MXML Component Dynamically

    srirama.83 Level 1
      Hi all,
      I am new to Flex and was trying out small things . I created a MXML Application and also MXML components.
      I tried loading MXML component to application using xmlns and it worked fine.(
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#ffffff" xmlns:mi="com.*">
      <mi:base1 id="base1" />
      <mi:base2 id="base2" />
      )
      This method is ok if we are loading 3-4 components .
      but , if i have to load a mxml component dynamically how do I do it?
      for example ,if base1 and base2 are two components and i want to load them based on some event performed.

      I have tried the method which uses ViewStack and code myViewStack.selectedChild=Container(myViewStack.getChildByName(selectedNode)) ,where each child will have one component declared or initialized.

      Following this method is not a feasible when we have hundred of components to be loaded.
      Can anyone help me on this??

        • 1. Re: Loading MXML Component Dynamically
          Level 7

          "srirama.83" <webforumsuser@macromedia.com> wrote in message
          news:gpkoui$g3u$1@forums.macromedia.com...
          > Hi all,
          > I am new to Flex and was trying out small things . I created a MXML
          > Application and also MXML components.
          > I tried loading MXML component to application using xmlns and it worked
          > fine.(
          > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          > layout="absolute"
          > backgroundColor="#ffffff" xmlns:mi="com.*">
          > <mi:base1 id="base1" />
          > <mi:base2 id="base2" />
          > )
          > This method is ok if we are loading 3-4 components .
          > but , if i have to load a mxml component dynamically how do I do it?
          > for example ,if base1 and base2 are two components and i want to load them
          > based on some event performed.
          >
          > I have tried the method which uses ViewStack and code
          > myViewStack.selectedChild=Container(myViewStack.getChildByName(selectedNode))
          > ,where each child will have one component declared or initialized.
          >
          > Following this method is not a feasible when we have hundred of components
          > to
          > be loaded.
          > Can anyone help me on this??
          >
          >

          http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf
          Q4