firegambler
Technical User
Hi Folks
I have a question on referencing objects:
In AS1 + AS2 when I used "this" within a function I was able to control the object calling the function.
Now in AS3 it seems as if this would always target the timeline on which the function is defined.
How can I make sure to reference the calling object without using the whole absolute path to it?
Example:
Earlier in AS2 I had a button, named button1.
Code written on the main timeline. Pressing the button moved the button.
Now in AS3, code - again - is written on the main timeline.
Pressing the button moves the whole film.
How can I achieve what I did in AS2 with AS3?
Thanks in advance
I have a question on referencing objects:
In AS1 + AS2 when I used "this" within a function I was able to control the object calling the function.
Now in AS3 it seems as if this would always target the timeline on which the function is defined.
How can I make sure to reference the calling object without using the whole absolute path to it?
Example:
Earlier in AS2 I had a button, named button1.
Code written on the main timeline. Pressing the button moved the button.
Code:
function moveright(){
this._x=this._x+5;
}
button1.onRelease=function(){
moveright();
}
Now in AS3, code - again - is written on the main timeline.
Pressing the button moves the whole film.
Code:
function MoveRight(event:MouseEvent):void
{
this.x+=5;
}
MC_button2.addEventListener(MouseEvent.MOUSE_DOWN, MoveRight)
How can I achieve what I did in AS2 with AS3?
Thanks in advance