Here is some code I am using to instantiate my ChatInvitation.mxml custom
component:

            var message:ChatInvitation = new ChatInvitation();
            chatBox.addChild(message);
            message.inviteLabel.text = e.getUserName() + " would like to
chat with you...";
            message.roomID = e.getEsObject().getInteger("roomID");
            message.userName = e.getUserName();


Note that I addChild() *before* changing variables.  I'm new to Flex and not
sure why but that seems to work better than trying to change variables
before addChild()


On 2/13/08, Tracy Spratt <[EMAIL PROTECTED]> wrote:
>
>    All you need is a variable declared with that data type.  Are you
> trying to avoid that?  You might consider generating a component with those
> bogus variables declared. Obviously that would take an extra step, but might
> be better than having to manually edit and recompile.
>
>
>
> Try the archives/google for this, it has been discussed very often.
>
>
>
> Tracy
>
>
>  ------------------------------
>
> *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
> Behalf Of *amywongwy
> *Sent:* Wednesday, February 13, 2008 3:11 PM
> *To:* flexcoders@yahoogroups.com
> *Subject:* [flexcoders] How to create a custom component dynamically by
> name?
>
>
>
> My current implementation assumes the data comes from an xml file,
> while specifies the class name of the custom component.
> In Flex, the getDefinitionByName(String) method allows me to have a
> class declaration of dynamically create a component. However, a
> limitation in Flex requires me to have a class declaration of the
> dynamic class in the component before I can call getDefinitionByName().
>
> Is there any way that I can create a custom component dynamically by
> name without creating a class declaration?
>
>  
>

Reply via email to