c0rnf3d
12-31-2009, 09:41 PM
I've made the jump from as2 (yes its been awhile since ive touched this) to flex.
Previous i was able to do something like (i know this isnt exact but you can see what i am attempting to do)
for(x = 0;x<10;x++)
{
this['buttonName' + x] = new LinkButton();
this['buttonName' + x].label = details[x];
this['buttonName' + x].addEventListener();
}
This no longer will work because i cannot create dynamic variable names (or at least im not smart enough to know how to yet)
I am loading in data externally and i need to create a link button for each item loaded in.
for(x = 0;x<10;x++)
{
var linkButton:LinkButton = new LinkButton();
linkButton.label = companyDetails[x];
linkButton.addEventListener(MouseEvent.CLICK, function (e:MouseEvent):void {
companySelected(e, x);
});
buttonBox.addChild(linkButton);
}
This works fine in that it creates the 10 buttons as desired but when x gets passed it will always be 9. In flash it would pass as the value of x at time of creation because a separate instance of x is created.
Anyways i need to be able to create X linkbuttons and then have each of those linkButtons pass something unique into the event. Hope this makes sense.
Previous i was able to do something like (i know this isnt exact but you can see what i am attempting to do)
for(x = 0;x<10;x++)
{
this['buttonName' + x] = new LinkButton();
this['buttonName' + x].label = details[x];
this['buttonName' + x].addEventListener();
}
This no longer will work because i cannot create dynamic variable names (or at least im not smart enough to know how to yet)
I am loading in data externally and i need to create a link button for each item loaded in.
for(x = 0;x<10;x++)
{
var linkButton:LinkButton = new LinkButton();
linkButton.label = companyDetails[x];
linkButton.addEventListener(MouseEvent.CLICK, function (e:MouseEvent):void {
companySelected(e, x);
});
buttonBox.addChild(linkButton);
}
This works fine in that it creates the 10 buttons as desired but when x gets passed it will always be 9. In flash it would pass as the value of x at time of creation because a separate instance of x is created.
Anyways i need to be able to create X linkbuttons and then have each of those linkButtons pass something unique into the event. Hope this makes sense.