Copy link to clipboard
Copied
Hi All,
I'm probably not using the correct search terms to find the answer in this forum:
I just need to find the x and y coordinates for an instance -relative to the stage.
(I'm publishing my FLA as a Canvas project using Animate CC.)
myCoordinate = this.myInstance.getBoundingClientRect();
alert (myCoordinate.top);
...Doesn't seem to work in my script window.
Thanks!
var instanceX=this.myInstanceName.x; // sim for y
Copy link to clipboard
Copied
var rect:Rectangle=this.myInstance.getBounds(this);
Copy link to clipboard
Copied
Thanks Kglad.
If I use the 'var,' the FLA fails (a blank browser window results when publishing), so I put this in my Animate script window:
rect:Rectangle = this.myInstanceName.getBounds(this);
alert(rect);
...but no alert shows in the browser window upon publish.
Does that syntax not work with an Animate (Canvas) project?
I also tried:
myBounds = this.myInstanceName.getBounds(this);
alert(myBounds);
...but he alert shows "[Rectangle (x=0 y=0 width=42 height=42)]" ---no x and y coordinates relative to the stage.
Am I doing something wrong? I just want to find the x and y coordinates (location) of the instance relative to the stage.
Thanks much
Copy link to clipboard
Copied
He appears to be working in a Canvas document.
Paul, getBoundingClientRect() is browser DOM method. It does not exist in the Animate canvas API. If your object is nested within another clip, you'll probably need to use localToGlobal. But if it's sitting directly on the stage, you just access the clip's x and y properties.
Copy link to clipboard
Copied
Clay UUID wrote:
"Paul, getBoundingClientRect() is browser DOM method. It does not exist in the Animate canvas API. If your object is nested within another clip, you'll probably need to use localToGlobal. But if it's sitting directly on the stage, you just access the clip's x and y properties."
Yes it's just sitting on the stage. How can I access (find) the X and Y properties to find the coordinates?
Thanks
Copy link to clipboard
Copied
var instanceX=this.myInstanceName.x; // sim for y
Copy link to clipboard
Copied
sheesh. Overthought that one. Thanks for your patience Clay UUID and Kglad.
Copy link to clipboard
Copied
paul_james123 wrote
Clay UUID wrote:
"Paul, getBoundingClientRect() is browser DOM method. It does not exist in the Animate canvas API. If your object is nested within another clip, you'll probably need to use localToGlobal. But if it's sitting directly on the stage, you just access the clip's x and y properties."
Yes it's just sitting on the stage. How can I access (find) the X and Y properties to find the coordinates?
Thanks
x is x. y is y. It's not complicated.