6 Replies Latest reply on Aug 6, 2009 8:02 AM by MoonlightWare

    Custom Component Help

    MoonlightWare Level 1

      I have created a custom MXML component base on the mx:Canvas and everything works great. However, How can I prevent someone from adding a component onto it as it is based on the Canvas. example: when I bring it into FLEX Builder I can add and drop other components on to it. I do not what that ability and want to prevent it from happening.

       

      Thanks

        • 1. Re: Custom Component Help
          Madhav Subedi Level 4

          what if you override the addChild method?

          • 2. Re: Custom Component Help
            MoonlightWare Level 1

            Sorry, but that did not help. I can still drop components in the design mode for FLEX Builder onto it. Anyone ELSE.

            • 3. Re: Custom Component Help
              Gregory Lafrance Level 6

              I went so far as to make an ActionScript component "final" and even that did not work.

               

              I also tried adding an event listener for the childAdd event and that did not work.

               

              If this post answers your question or helps, please mark it as such.

              • 4. Re: Custom Component Help
                Ansury Level 3

                Hmm, modifying UI components in design mode isn't going to generate flash events that you can intercept, I'm pretty sure it's only rendering the visual aspects of components.  I'd be a little surprised if it was even running a full Flash VM.

                 

                Which version of Flex Builder are you running? I'm not seeing this behavior in 3 at all. If I have a plain component based on a canvas with nothing added, the designer lets me (FB3) drop things into that empty canvas like you say you're seeing. But once I add a child to the custom component, the designer doesn't allow additions from a higher level container and always drops new components inside the higher level container instead of the custom.

                 

                Also, verify that it's actually placing the components inside the container.  If you have your custom component inside a container with an absolute layout, you'll be able to drop other components on top of the custom one.  You'll definitely never be able to prevent that from happening.  So even if it's letting you add components 'inside' your custom component "container", fixing that still won't prevent someone from altering the appearance or visible components on your custom component.

                • 5. Re: Custom Component Help
                  Ansury Level 3

                  In fact, if you try to circumvent the designer completely and add a component inside your custom component from a higher level component (IF your custom component already has children added), you get an error saying "multiple sets of visual children have been specified for the <class> tag", so the version I'm using at least definitely does not allow this if you've already specified children for the container.

                  • 6. Re: Custom Component Help
                    MoonlightWare Level 1

                    I am using FLEX Builder 3.0.2.214193

                     

                    When I create a MXML (not an as class)  Component based on the Canvas, add a button to it or any think else and then us in in another application as a SWC file I can drop components onto it in FLEX Builder and it actually place's it inside the components section of the MXML. That is what I cam trying to prevent. What I have created is a bullet graph component and am close to releasing it for use but not until I prevent this from happing.