Copy link to clipboard
Copied
Hi,
I'm new to createJS.
I tried an object to move along with mouse on stage. I have a movieclip with the instance name of "mc1" and have given the below code on the frame.
stage.addEventListener("stagemousemove", function(evt) {
this.mc1.x = evt.stageX;
this.mc1.y = evt.stageY;
});
Nothing happening in the browser when I move mouse on the stage. When I try to alert(this.mc1), it says "undefined"
Please help me how to make it works.
Thanks,
Guru
Copy link to clipboard
Copied
Create a variable outside your function to store the correct scope.
var that = this;
stage.addEventListener("stagemousemove", function(evt) {
that.mc1.x = evt.stageX;
that.mc1.y = evt.stageY;
});
Copy link to clipboard
Copied
Thanks you Joae .
Sorry for my very late reply. I was in the other task.
Copy link to clipboard
Copied
No problem!
You're welcome!