开发者

Why won't this code work?

开发者 https://www.devze.com 2023-02-05 00:07 出处:网络
开发者_开发百科This is a simple actionscript code.Why won\'t it work? for (var inc = 1; inc <= 18; inc++)
开发者_开发百科

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号