Skip to main content
Inspiring
March 22, 2025
Answered

New instance coordinates different to stage coordinates

  • March 22, 2025
  • 1 reply
  • 301 views

Hi

I'm trying to find the coordinates for placing a new instance of a movie clip on the stage. 

When I manually place the movie clip, the coordinates are x = 216, y = 148 - which is what I'd expect.

But to get it in approximately the same position on stage with code, I have to change the coordinates. The code I'm using is:

var ant = new lib.ant()
ant.x = 135
ant.y = 0
ant.scaleX = 0.15
ant.scaleY = 0.15
this.addChild(ant)

Why is this? What are the coded coordinates relative to, if not the stage?

Presumably the anchor point is the same whether it's placed manually or with code? Could it have anything to do with the fact that the movie clip is scaled?

Thanks for any help.

Correct answer pauls73381349

Never mind, I've sorted it. It was the scaling thing. I created a movie clip from a smaller graphic that didn't need scaling, and it appeared in the correct position.

1 reply

pauls73381349AuthorCorrect answer
Inspiring
March 22, 2025

Never mind, I've sorted it. It was the scaling thing. I created a movie clip from a smaller graphic that didn't need scaling, and it appeared in the correct position.

Inspiring
March 22, 2025

Cancel that - I'm still having problems.

The movie clip's top left point is going to the stated coordinates. I would like the bottom centre of the clip to be used instead. I'm trying to change the registration point using _x and _y, but I need to be able to set the _x value as half of the width of the movie clip, then multiply it by -1 (I think). But I'm struggling to reference the width of the movie clip's instance. I've tried ant.width but that doesn't work. Any ideas?

Thanks.

Inspiring
March 22, 2025

Sorry - I don't mean _x and _y - I mean regX and regY.