我是 actionscript 3 的新手,将“this”关键字从 as2 转换为 as3 时遇到问题。请帮我!
谢谢 !
我的 as2 代码是:
var selected = MovieClip(null);
j = 1;
while (j++, j <= 11)
{
var obj_1 = this["shape" + j];
obj_1.highlight._visible = false;
obj_1.onPress = function()
{
if (_root.selected)
{
_root.selected.highlight._visible = false;
}
// end if
this.highlight._visible = true;
_root.selected = this;
trace(this)
};
}// end while
我的 as3 代码是:
var selecteD = MovieClip(null);
var j:int = 1;
while (j < 11)
{
j++;
var obj_1:MovieClip = this['shape' + j];
//trace(obj_1);
obj_1.highlight.visible = false;
obj_1.addEventListener(MouseEvent.CLICK, pressed);
function pressed(event:MouseEvent):void
{
if (MovieClip(root).selecteD)
{
trace(MovieClip(root).selecteD);
selecteD.highlight.visible = false;
}
MovieClip(root).selecteD = **this**;
MovieClip(root).selecteD.highlight.visible = true;
}
}
当我追踪这个结果时,结果来自 as3 中的对象主时间线,但在 as2 中它是 level0.shape11
我怎样才能为这个项目转换“这个”。
请帮忙!