I found one of Alex's posts.  Here is the text:

 

"Once a month this issue comes up.  Because there is no function
olverloading in AS3, we can't change the parameter list of addChild, but
basically, frameworks have rules and the rules for Flex are:

 

Navigator children must be Containers

Container children must be IUIComponents

UIComponent children can be anything.

 

I swear I replied to this thread two days ago, but answer is to
instantiate a UIComponent and addChild your sprite to it.

"

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Monday, May 05, 2008 6:11 PM
To: [email protected]
Subject: RE: [flexcoders] Child items in custom component

 

There are rules for what children can be added to what parents.  Is it
possible you are not following those rules?  "sprite" is a much lowe
level class than I have ever used, are you sure it can accept the child
you are adding?

 

Alex has posted these rules multiple times.   Something like:

Container can accept container or UIComponent, UIComponent can accept
anything, ... etc I do not know whare sprite fits into that.

 

Tracy 

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Weyert de Boer
Sent: Monday, May 05, 2008 5:49 PM
To: [email protected]
Subject: Re: [flexcoders] Child items in custom component

 

Sorry, to bug, but does anyone happen to have any ide?

Weyert

> Hello!
>
> I am currently a bit clueless regarding using Flex components. I am
> currently trying to port a .NET component to Flex. Only I have some
> problems. In a simplified form the problem is that I am trying to add
> childs to the component. The idea is to use public method to add nodes
> to the component. The code could be:
>
> var node: MyNode = new MyNode();
> node.width = node.height = 125;
> myComponentInstance.addNode( node );
>
> The addNode-method is basically contains:
>
> public function addNode( node: MyNode ): void {
> _nodeContainer.addChild( DisplayObject(node) );
> invalidateDisplayList();
> }
>
> The _nodeContainer is a Sprite class which gets created in the
overriden
> createChildren-method. Now I would be expected that the
MyNode-instance
> (which just draws a simple rectangle 125x125) would be shown. Sadly
> enough, this is not the case.
>
> Does anyone know what should be done to get this working?
>
> Yours,
> Weyert de Boer
>
> 

 

Reply via email to