what if you override the addChild method?
Sorry, but that did not help. I can still drop components in the design mode for FLEX Builder onto it. Anyone ELSE.
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.
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.
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.
I am using FLEX Builder 18.104.22.168193
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.