我该如何做这项工作?我需要从引用中删除单词Button来引用将被着色的实际项目。先谢谢你。AS3参考按钮
disagreeButton.addEventListener(MouseEvent.ROLL_OVER, mouseRollOver);
contentMain.clickButton1.addEventListener(MouseEvent.ROLL_OVER, mouseRollOver);
function mouseRollOver(e:MouseEvent):void {
var c:Color = new Color();
c.setTint (0xFFFFFF, 1);
//the issue is this line:
this[e.target.name.replace("Button", "")].transform.colorTransform = c;
}
什么是错的这个解决方案?它是否编译?跑?有意想不到的副作用? – 2012-04-11 17:35:39
TypeError:错误#1010:术语未定义且没有属性。 \t at index_test_fla :: MainTimeline/mouseRollOver() 只为“contentMain.clickButton1”得到这个错误 – Anderson 2012-04-11 17:48:35
您是否测试了e.target.name.replace(“Button”,“”)'评估您的想法它呢? – 2012-04-11 17:49:31