When you declare <mx:RadioButton id="f1"/> in MXML, the RadioButton instance does indeed have its 'name' property (and its 'id' property) set to the String "r1". However, this isn't what allows you to access the RadioButton instance using code like r1.label. To make that work, the MXML compiler autogenerates an instance var

 

    var r1:RadioButton;

 

in your Application or MXML component, rather than a local variable inside a method like you've done. When you create components dynamically, you can use the same technique:

 

    <mx:Script>

 

        public var r:RadioButton; 

 

        private function someMethod():void

        {

            ...

            r = new RadioButton();

            addChild(r);

            ...

        }

 

    </mx:Script>

 

You can then use 'r' anywhere in your script to access the RadioButton.

 

- Gordon

 


From: [email protected] [mailto:[email protected]] On Behalf Of Jeremy Lu
Sent: Tuesday, June 13, 2006 8:16 PM
To: [email protected]
Subject: Re: [flexcoders] Duplicating controls dynamically

 


how about this ?

var r:RadioButton = new RadioButton();
r.name = "r1";
this.addChild( r );

On 6/13/06, Aasim Momin <[EMAIL PROTECTED]> wrote:

I achieved that but how do I assign unique ID's to each of them.

Could you demonstrate this via a small snippet of code.

 

Regards,

Aasim


From: [email protected] [mailto: [email protected]] On Behalf Of Jeremy Lu
Sent: Tuesday, June 13, 2006 5:47 PM
To: [email protected]
Subject: Re: [flexcoders] Duplicating controls dynamically

 


no duplicateMovie() anymore,
try this whenever you need a new radio button.

var r:RadioButton = new RadioButton();
this.addChild( r );

On 6/13/06, Aasim <[EMAIL PROTECTED]> wrote:

Hi,

I am new to Flex. I would like develop an application which has a
number of radio buttons. How could i possibly duplicate them
dynamically?

Is there anyhing like duplicateMovieClip (as in Flash IDE).

Please suggest.

Regards,
Aasim

 

 

__._,_.___

--
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