Assigning a name property is not recommended; the framework expects to
be able to use the name property of some DisplayObjects for its own
purposes.

 

Simply declare a public var in your <mx:Script> such as

 

    public myButton:Button;

 

When you dynamically create the component, store it in this var:

 

    ...

    myButton = new Button();

    ...

 

Then you can use myButton just as if it had been declared with

 

    <mx:Button id="myButton"/>

 

The purpose of the id property is simply  to tell the MXML compiler what
to name the var that it automatically creates to hold the reference.

 

- Gordon

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Mikhail Shevchuk
Sent: Thursday, February 08, 2007 4:47 AM
To: Flex
Subject: [flexcoders] Re: How to get object by id?

 

Heh, the solution was close enough to me.

I just have to assign a name property, not the id one. After that, I can
access to the text property of this object by:

Object(super.getChildByName("dateFrom")).text 



2007/2/8, Mikhail Shevchuk <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >:

I decided to extend this question a little bit: There are some objects
of DateField, TextInput, and others that are created using AS3
dynamically. I have also an array of ids as String objects. How can I
access these objects using that array? 

2007/2/8, Mikhail Shevchuk <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >: 

        Is there any way to get the programmatically created object if
it's id is known? 
        Or how can I get a property of such object?
        
        Thanks in advance!
        
        -- 
        A vivid and creative mind characterizes you. 




-- 
A vivid and creative mind characterizes you. 




-- 
A vivid and creative mind characterizes you. 

 

Reply via email to