Here's a response from Gordon to a similar question I had way back:

What does your component extend? If you're extending a Container, you can only use addChild() to content children which implement the IUIComponent interface. In order to support the LayoutManager, a content child has to implement things like measure(), etc.

 

However you should able to add it as a non-content or "chrome" child by doing rawChildren.addChild(myButton). Non-content children don't undergo automatic sizing and layout, so you'll have to set the size and position of myButton yourself.

 

- Gordon

 



On 8/11/06, danfrap767 <[EMAIL PROTECTED]> wrote:

I thought so too, as it even says in the addChild for a Canvas
documentation that it takes a display object.

but for some reason when I test and after attaching the canvas I then
attach the sprite I still get that same error:



"TypeError: Error #1034: Type Coercion failed: cannot convert
flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent."

Why would it try to convert that?

this is the bit of code from the function , and the drawn bg and the
button show up totally fine.

contentBg = new Canvas();
contentBg.graphics.beginFill(0xFF0000);
contentBg.graphics.lineStyle(2, 0xFFFFFF);

contentBg.graphics.drawRoundRect(0, 0, 150, 400, 10, 10);
contentBg.graphics.endFill();
addChild(contentBg);

changeButton = new Button();
changeButton.label = returnData.buttons.button.label;
changeButton.move(30, 30);
changeButton.addEventListener(MouseEvent.CLICK, someFunction);
contentBg.addChild(changeButton);

mySprite = new Sprite();
mySprite.graphics.beginFill(0xFFFFFF);
mySprite.graphics.drawRoundRect(300, 0, 150, 400, 10, 10);
mySprite.graphics.endFill();
contentBg.addChild(mySprite);

any ideas?


--- In [email protected], "dadrobson" <[EMAIL PROTECTED]> wrote:
>
> You should be able to use Canvas.addChild(Sprite), because it takes a
> DisplayObject, and Sprite does exted DisplayObject.
>
> I don't have time to test it right now, but based on the inheritance
> outlined in the docs, it looks like it should work. I'll try to run a
> test later; meanwhile, if you have a chance to test it, please let me
> know what you learn.
>
> -Jim
>


__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to