Jump to content
Search Community

Size tweening help please

theRexMundi test
Moderator Tag

Recommended Posts

I'm having problems getting a tween to work properly. You'll have to bear with my question, as I can't supply the full code to back it up:

 

I have a series of small movie clips (as children) to a main movie clip.

 

On mouseover of these child movie clips, I want the clip (which is a shape) to expand to double the size from its center point.

 

however, when I use, scalex, scaley or setSize, or even width height, the clip expands but also moves in an x and y position.

 

I can't seem to figure out how to stop this from happening, and to get the clip to expand from its top left x/y position.

 

i've tried this:

 

TweenMax.to(clip, 1.75, { width: 200, height: 200});

TweenMax.to(clip, 1.75, { setSize:{width: 200, height: 200}});

TweenMax.to(clip, 1.75, { scaleX:1.5, scaleY:1.5});

 

each one moves the object along its x and y as well as increasing its size..

 

Any ideas?

Link to comment
Share on other sites

There must be some misunderstanding on your end - those tweens will NOT change the x/y coordinates. To test, you could trace() the x/y coordinates before and after the tween:

 

trace("before: "+clip.x+", "+clip.y);
TweenMax.to(clip, 1.75, { width: 200, height: 200, onComplete:report});
function report():void {
   trace("after: "+clip.x+", "+clip.y);
}

 

Remember that scaling will always occur from the registration point. So if your registration point is in the center of the object, it will grow/shrink from the center. If you want the top left corner to remain in the same position, make sure you build it so that the registration point is there. Alternatively, you could use the transformAroundPoint plugin to make things scale from ANY point (this plugin is only available to "Really Green" Club GreenSock members and above). See an example in the Plugin Explorer.

 

Does that help?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...