I am very new in actionscript 3 I have a problem to convert "this" keyword from as2 to as3. please help me!
thanks !
My as2 code is:
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
and my as3 code is:
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;
}
}
when i trace this the result come Object main timeline in as3 but in as2 it is the level0.shape11
how could i convert "this" for this project.
please help!