Skip to main content
October 19, 2007
Question

Setting the center ponit of sprites and movieclips.

  • October 19, 2007
  • 4 replies
  • 492 views
Hi, I was wondering if it is possible to use code to set the center point of a Sprite and/or a MovieClip to better handle zoom and rotation...
This topic has been closed for replies.

4 replies

kglad
Community Expert
Community Expert
October 19, 2007
with as2 there is a publically available class that will do the abstract thinking for you. otherwise, you just have to wrap your head around ds'es suggestion.
October 19, 2007
Yeah, I was afraid to get this answer... I need to do this since old times of as2 without much success... Anyway, thanks a lot...
kglad
Community Expert
Community Expert
October 20, 2007
after thinking about ds'es answer i realized this is much easier in as3 than it was in as2 because you can re-parent displayobjects. here's a class that does just that and fakes a reg point change:

kglad
Community Expert
Community Expert
October 19, 2007
there's no way to do that. you can fake it, but even that's not easy.
Inspiring
October 19, 2007
Lujunq,

> Hi, I was wondering if it is possible to use code to
> set the center point of a Sprite and/or a MovieClip
> to better handle zoom and rotation...

You mentioned Sprite, which leads me to believe you're talking about
ActionScript 3.0. Either which way -- AS3 or AS2 -- I tend to use this
approach: create your movie clip (or sprite), draw or load its content,
then, when it has a width and height of its own, wrap it in a container
movie clip (or sprite) and offset the x and y coordinates of the first by
minus half its width and height. From the point of view of the container,
that gives you a centered registration point. Naturally, you can position
the inner object by its lower right corner, or anywhere else, using the same
trick.


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."