3 Replies Latest reply on Jan 26, 2009 4:24 AM by Kenchu1

    Making it possible to add children to custom container

    Kenchu1 Level 1
      I'm just curious. What exactly is it that makes it possible to add children to a component? For example, if you've got a <mx:Canvas> component, and then type "<" inside of it, you get a list of components that are possible to add to it. What is it that decides which components that are possible to add?

      I was experimenting a little bit with a custom actionscript class. I found out that unless you extend Container, you won't be able to add children (like for example buttons and textfields). But when looking at the source of Container, I couldn't find what exactly it is that makes it possible to add children to it.

      So I guess what I'm wondering is how you make your custom container class (that doesn't extend Container), just out of curiosity. :)

      Thank you
        • 1. Re: Making it possible to add children to custom container
          ntsiii Level 3
          Flex is a framework, with lots of integration and rules between its parts in order to provide the functionality it does. The run-time displayList dom, for example.

          One basic set of rules is:
          Navigator children must be containers
          Container children must be IUIComponets
          UIComponent children can be anything

          You can make a "custom container", just start with UIComonent. But that container will not have the functionality of Flex Container class.

          The lower you start in the class hierarchy, the more work you have to do yourself.

          So a question like "Why not extend Container" is valid.

          • 2. Re: Making it possible to add children to custom container
            levancho Level 3
            quote:

            So I guess what I'm wondering is how you make your custom container class (that doesn't extend Container), just out of curiosity. :)

            look at the source code of already implemented containers that adobe engineers did



            • 3. Re: Making it possible to add children to custom container
              Kenchu1 Level 1
              Now when I think about it, I think what I'm really curious about is the ctrl+space feature. How does flex editor know that a certain component only can have children of certain types? If I was to make my custom class, how can I make it only accept children of a certain type?

              <myPack:MyClass>
              <myPack:MyOtherClass />
              </myPack:MyClass>

              For example. And when I type "<" within "<myPack:MyClass>" and press ctrl+space, only MyOtherClass will be displayed. How would you do that?