RE: [Flashcoders] simple math question...

2007-03-14 Thread Rebecca Roberts
An easy way to do this is to build your movieClip so that the graphics inside align in the upper left corner at (0, 0). Then take the width of your movie and divide it in half. If you take this half-width value and subtract it from your _xmouse then it should center your movieClip over the mouse ho

Re: [Flashcoders] simple math question...

2007-03-02 Thread T. Michael Keesey
On 3/2/07, JOR <[EMAIL PROTECTED]> wrote: sweet tip, thanks. -- JOR No prob. Incidentally, I'm pretty sure this is why BlurFilter, etc. are optimized for blur amounts that are powers of 2. -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To chan

Re: [Flashcoders] simple math question...

2007-03-02 Thread JOR
sweet tip, thanks. -- JOR T. Michael Keesey wrote: On 3/2/07, Karina Steffens <[EMAIL PROTECTED]> wrote: If your mc's reg point is top left: mc._x = _root.xmouse - mc._width/2 mc._y = _root.ymouse - mc._height/2 Incidentally, there's a neat trick you can do to speed up the calculation

Re: [Flashcoders] simple math question...

2007-03-02 Thread [p e r c e p t i c o n]
thanks for the info...very helpful! cheers [p] On 3/2/07, Joshua Sera <[EMAIL PROTECTED]> wrote: For an arbitrary registration point, use var b:Object = mc.getBounds(mc._parent); var offset:Object = {x:(mc._x - b.xMin, y:instance._y - b.yMin)}; then mc._x = (_root.xmouse - mc._width/2) - of

Re: [Flashcoders] simple math question...

2007-03-02 Thread Ian Thomas
It depends where the registration point of your clip is. If it's at top-left or centre, then the calculation is simple - see all the other posts in the thread. If it's unpredictable, use getBounds() - do something like this: var bounds:Object=myClipToCentre.getBounds(this); myClipToCentre._x=_xm

RE: [Flashcoders] simple math question...

2007-03-02 Thread Joshua Sera
For an arbitrary registration point, use var b:Object = mc.getBounds(mc._parent); var offset:Object = {x:(mc._x - b.xMin, y:instance._y - b.yMin)}; then mc._x = (_root.xmouse - mc._width/2) - offset.x; mc._y = (_root.ymouse - mc._height/2) - offset.y; --- Karina Steffens <[EMAIL PROTECTED]>

Re: [Flashcoders] simple math question...

2007-03-02 Thread T. Michael Keesey
On 3/2/07, T. Michael Keesey <[EMAIL PROTECTED]> wrote: In a test where I ran a calculation a million times, shift right was about 200ms faster than division. Sorry, that's not a helpful metric. I should have said shift right took ~90% as much time. -- Mike Keesey

Re: [Flashcoders] simple math question...

2007-03-02 Thread T. Michael Keesey
On 3/2/07, Karina Steffens <[EMAIL PROTECTED]> wrote: If your mc's reg point is top left: mc._x = _root.xmouse - mc._width/2 mc._y = _root.ymouse - mc._height/2 Incidentally, there's a neat trick you can do to speed up the calculation AND ensure that the result is an integer (so that the cl

Re: [Flashcoders] simple math question...

2007-03-02 Thread [EMAIL PROTECTED]
MovieClip._width / 2 = its _x center MovieClip._height / 2 = its _y center hope it helps [p e r c e p t i c o n] wrote: good people, how do i move a moviClip to center itself at (_xmouse, _ymouse)...i have the onPress part down...i just need to center it on those coordinates thanks _

Re: [Flashcoders] simple math question...

2007-03-02 Thread Yehia Shouman
dont forget updateAfterEvent(); with the MouseMove use. it tells the player to refresh visuals after the calculated mouse move event you catched even if it wasn't time to render that frame. On 3/2/07, Yehia Shouman <[EMAIL PROTECTED]> wrote: 1) either double click your clip and group everthing

Re: [Flashcoders] simple math question...

2007-03-02 Thread Yehia Shouman
1) either double click your clip and group everthing and center it manually OR 2) make sure your graphics inside that clip is at 0,0 and then inside your MouseMove handler or onEnterFrame handler; toCenterClip._x = _xmouse - (toCenterClip._width/2); toCenterClip._y = _ymouse - (toCenterClip._hei

Re: [Flashcoders] simple math question...

2007-03-02 Thread JOR
Try: // movie_mc is the instance name of the movieClip // you want to center on the mouse coords. movie_mc._x = _xmouse - (movie_mc._width/2); movie_mc._y = _ymouse - (movie_mc._height/2); If the movieClip size doesn't change you can optimize this by precalculating the (movie_mc._width/2) and (

RE: [Flashcoders] simple math question...

2007-03-02 Thread Karina Steffens
If your mc's reg point is top left: mc._x = _root.xmouse - mc._width/2 mc._y = _root.ymouse - mc._height/2 if it's centered you need not bother about the width/2 etc, but if it's somewhere else, you'll need to change it or do other calcualtions. Karina > -Original Message- > From: [p