In your example, you store the ith TextInput instance as myArray[i][0] and the ith CheckBox instance as myArray[i][1]. So loop over i and check whether myArray[i][1].selected is true.

 

The name of the local var chkCheckBox is completely irrelevant; this var doesn't even exist after the function createStuff() returns.

 

- Gordon

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of kristian_wright2002
Sent: Wednesday, October 04, 2006 1:50 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Creating variable name dynamically

 

I'm in a situation where I need to create a number of components at
runtime, at different time intervals. A user presses a button and I
create a set of components. They press the button again, and another
set of the same components is created.

My problem is that one of the components created is a checkbox, which
needs to be used later. I can store component information in an array
so I can reference it later, but the problem is that the information
in the array will only hold the initial value of the checkbox, and not
the current value.

Currently I have a function like the following that creates the
required controls when the button is pressed:

private function createStuff():void
{
if (index < maxLimit)
{
var chkCheckbox:CheckBox = new CheckBox;
var txtInput:TextInput = new TextInput;
myArray[index] = [txtInput, chkCheckbox];
index++;
}
}

This is a simplified version, but it works as intended. I have a
function that does stuff with these components, but only the selected
ones. How can I tell what checkbox is selected? They are all called
chkCheckbox! I need to have a unique name for each one, so I can loop
through them and use this["chkCheckbox"+i].selected to see which ones
I perform the 2nd function on.

What's the best way to achieve this? I've tried using a repeater, but
since the dataprovider is empty at the start of the app, it doesn't
seem to update the repeater. Unless I'm using the repeater wrong...

Any help would be greatly appreciated!!!!

Thanks,
K.

__._,_.___

--
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
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to