I need the ability to create an ID on-the-fly. Is this
possible in Flex? I'm trying to transition some of my current apps
from Ajax to Flex, and this will be devastating blow to my efforts
if this isn't possible. Thanks.
You can change the ID of any control on the fly if it has an
ID already or, if you are creating the control progrmatically and
then adding it to a container of some sorts you can set it's ID
during creation or change it's ID afterwards.
var label:Label = new Label();
label.id = "lblStatus";
label.text = "Control created.";
if you wanted to invoke some sort of method belonging to the
control in a different routine you could then add the control to an
array of DisplayObjects and then search it using the ID (which all
DisplayObjects have), then when a match is found cast that
particular item in the array to the appropriate type (in this
example "Label") then invoke one of the labels methods.
for each (var object:DisplayObject in objectList)
if(object.id == "lblStatus")
var label:Label = Label(object);
// or Alert.show(Label(object).text);