2 Replies Latest reply on Jun 5, 2010 4:50 PM by SpaghettiCoder

    Define components in MXML, but do not add them to the parent? SDK 3.5

    -skitch- Level 1

      Is there a way to define components in MXML that do not automatically get added to the parent component?

      Basically I want to create a component, but never add it to the parent component.

       

      Say I have the following code:
      <mx:Canvas
          xmlns:mx="http://www.adobe.com/2006/mxml">
         
          <mx:HBox>
              <mx:Button/>
              <mx:Button/>
          </mx:HBox>
         
      </mx:Canvas>

       

      How do I make it so that the HBox is created, but not added to the Canvas (without the use of states too please)?

        • 1. Re: Define components in MXML, but do not add them to the parent? SDK 3.5
          SpaghettiCoder Level 3

          created but not showing up ?

           

          visible="false"

           

          or don't even define it in mxml, just create the component when you want in actionscript.

          • 2. Re: Define components in MXML, but do not add them to the parent? SDK 3.5
            -skitch- Level 1

            Well put it this way, I have a bunch of main views that have existing buttons written in MXML.

             

            A task I have been given is to make some of the main buttons for each page show up in the applications hot bar (place where action buttons would go and it's a few levels up in the hierarchy).  The way I'm going about this is when a view in my viewstack becomes visible, it sends a set of buttons (or HBox with buttons) to a UIComponent that I have stored in my singleton model.  My hot button bar view is binded to that UIComponent in the model and when it changes it adds that component to itself and removes it when necessary.  Basically whatever view is visible regulates whats in the hot button bar.

             

            When I pass the actual component and add it to another parent component, this removes the original parent (in the view).  When I switch away from the view, I never add the button set back to the view's original parents and therefore the button is defined in MXML, instantiated and can be referenced, but not added to the parent component in the view.

             

            It would be nice if I could keep the MXML convention and not have to change the components themselves, such as changing properties like visible and includeinlayout.

             

            I just want to be able to define some components without adding them to a parent component while the view is being created.