How to dynamically change the transformation/pivot point of a movieclip?
A Flash Developer Resource Site

# Thread: How to dynamically change the transformation/pivot point of a movieclip?

1. ## How to dynamically change the transformation/pivot point of a movieclip?

Hey guys,

I have a new project where the user can click on a movieclip and zoom in to the point where they clicked. Im thinking to do this i'll need to dynamically modify the transformation/pivot point to the point they clicked (tween it) and then scale the object. Which leads to the question...

Does anyone know how to modify the transformation/pivot point of a movieclip object? Is this even possible? Are there any other alternatives to zooming in on a movieclip? I'm thinking maybe move the object across and up/down while i scale (if its not possible to modify transformation point).

Any help would be appreciated,
Thanks

2. This is really hard for me to describe properly, but I'll give it a go.

You can use math to do the whole thing. Your object that you are zooming in on, needs one other 'object' for reference. It should be the object that will be masking it (unless it takes up the whole stage, if that's true, then use the stage).

If I remember off the top of my head correctly, when you zoom, there are three steps.

First, you need to capture, the local x and y of the object zooming, in relation to the viewable are (object masking) as a percentage.

Second, change the scale of the movie clip. simple.

Last, after you make your object bigger, you capture the new location as the first, and subtract the two. This will cause the same point on the object zooming, to move back to the position it was before, the center of the viewable area.

The math I have may not be the best or most efficient, but it works. I'll find it tomorrow.

3. Thanks for the reply Baby Minion. Sounds like a good technique, im looking forward to seeing the math behind it.

4. just wanted to let you know, I'm in the middle of switching to a new PC, and I don't think I can get the code till tomorrow. sorry for the delay.

5. You can get around this with two wrappers (double-bag-it joke here) - I find it's most helpful if you start with everything centered against the true registration points.

Apply all translations (eg. movement and rotation) to the inner clip. However you move things around inside, they will retain that outer clip's origin as a point of reference. So when you're ready to scale/zoom just apply that to the outer clip.

6. as neznein9 stated use another moviclip centered then the clip placed inside this clip will act like the registration/pivot point

7. Thanks for the help guys. I think i understand. So basically use the inner clip to move the movieclip around and the outer clip to scale it? I'll give it a shot. Sounds like a good technique.

BTW, I'm still keen to check out your code Baby Minion.

8. Hey, I finally gots everything I needed. I actually spent some time to try to explain some of the math. It took me 3+ months to figure out.

I've got an fla and a swf for you to look at.

SWF

FLA

The other guys are probably right, and it could work that way too. The math I have may not be the most efficient, and I think, if I spent the time, the globalToLocal() method would make life easier, but hey, I can't complain!

Also, the code is in AS2, but it shouldn't take much at all to change it for AS3

GL

K

9. Thanks man. Looks like it works really well. It seems a bit more complicated than the other method tho. I'll use your technique if the other one doesn't work out. Thx.

10. ## Good Work Dude

Originally Posted by Baby Minion
Hey, I finally gots everything I needed. I actually spent some time to try to explain some of the math. It took me 3+ months to figure out.

I've got an fla and a swf for you to look at.

SWF

FLA

The other guys are probably right, and it could work that way too. The math I have may not be the most efficient, and I think, if I spent the time, the globalToLocal() method would make life easier, but hey, I can't complain!

Also, the code is in AS2, but it shouldn't take much at all to change it for AS3

GL

K
Hey, I read the post and see how beautifully you solve the issue. I was finding the same solution but I required it in AS3. Can anyone here help me? I need exactly same file in AS3.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap