为什么不这样code的工作? [英] Why won't this code work?

查看:91
本文介绍了为什么不这样code的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的动作code。为什么不工作?

 的(VAR INC = 1; INC< = 18; INC ++)
{
    电流=CB+增量;
    current.addEventListener(Event.CHANGE,storedata);
}
 

解决方案

什么你大概意思做的是这样的:

 的(VAR INC = 1; INC< = 18; INC ++)
{
    这种[CB+ INC] .addEventListener(Event.CHANGE,storedata);
}
 

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);
}

这篇关于为什么不这样code的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆