我該如何做這項工作?我需要從引用中刪除單詞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