Why won't this code work?
This is a simple actionscript code. Why won't it work?
for (var inc = 1; inc <= 18; inc++)
{
current = "cb"+inc;
current.addEventListener(Event.CHANGE, storedata);
}
What you are probably meaning to do is this:
for (var inc = 1; inc <= 18; inc++)
{
this["cb"+inc].addEventListener(Event.CHANGE, storedata);
}
current
in your code seems to be a String
. You can't add an event listener to a String
.
精彩评论