Skip to main content
Known Participant
April 16, 2009
Answered

movieclip names and coordinates

  • April 16, 2009
  • 2 replies
  • 685 views

Three questions:

1) Say I have a movieclip instance named myMC, positioned at 0,0 (according to the properties panel) but getting the _x _y values in a script yield 40,40? (apparently the center position)
How do I reconcile this discrepancy?

2) Why does this:

trace(myMC._x);

yield 40, while this:

currentmc = "myMC";
trace(currentmc._x);

yield undefined?

3) Why can't movieclip instances be named numbers? Well, technically, I can name them numbers, but trying to then reference them in a script generates errors.

This topic has been closed for replies.
Correct answer kglad

change the extension on your fla file to swf and attach it to this forum.

2 replies

Inspiring
April 16, 2009

Despres,

Check the registration point of "myClip". It sounds like the graphics inside "myClip" are centered and the registration point of your clip is top left (which is default.

If this is the case, try adjusting your graphics from inside "myClip" and that should fix your trace issue.

M.

Desprez10Author
Known Participant
April 16, 2009

I think that appears to be the case.

I don't know how to change the registration or any of that, but the coordinates reading from the center in actionscript is more usefull to me anyway.

So I'll probably just leave it as is.

kglad
Community Expert
Community Expert
April 17, 2009

the properties panel should reflect the reg pt's location and the trace() function should report the reg pt's location.  because your movieclip's upper left is at the stage upper left when the properties panel reports the x,y to be 0,0, you can infer your movieclip's reg point is the upper left.

kglad
Community Expert
Community Expert
April 16, 2009

1.  your script is not retrieving the same _x and _y properties or they have changed.

2.  currentmc is a string variable and strings don't have _x properties.  flash can coerce strings into objects (including movieclips) using array notation:

currentmc = this["myMC"];

trace(currentmc._x);

3.  because numbers look like memebers of the number class to flash.  in fact, you shouldn't start the name of any object, in flash, with a number.

Desprez10Author
Known Participant
April 16, 2009

Thanks for the reply.

Can you elaborate on point 1? I'm confused how it can have different sets of _x _y coordinates, and the movieclip has not moved.

I place a movieclip instance (myMC) at 0,0 according to the properties pannel, which puts the upper left corner of the clip at the upper left corner of the stage.

Then I have this in frame one:

trace(myMC._x);

trace(myMC._y);

And I get 40, 40, not 0, 0.

Nothing has moved or changed, and there is not much else in the file at this time.

It appears the properties pannel places things by the upper left corner of the clip, where as actionscrip references the center of the clip.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 16, 2009

change the extension on your fla file to swf and attach it to this forum.