Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
kiogo

Update and Tween Liquid Area

Recommended Posts

Hello,

 

Is it possible to update a liquid area on the fly? Basically I have 3 positions that I need my mc to adapt to. For example:

 

Starts at: area.attach(mc, {scaleMode:ScaleMode.STRETCH});

 

Then via an event, I want the mc to tween to: area.attach(mc, {scaleMode:ScaleMode.HEIGHT_ONLY});

 

And another event would pin the same mc to the left of the screen: area.attach(mc, {scaleMode:ScaleMode.HEIGHT_ONLY, hAlign:AlignMode.LEFT});

 

Is it possible to update the liquid area params this way? And tween between the changes?

 

Thanks for any help!

Link to post
Share on other sites

Well, not really - you can't tween the scaleMode but you could get that effect with some clever coding :) Just record the old transform values (x/y/width/height), then attach() it at the new/destination mode and use that size to plug into a width/height/x/y tween and then re-apply the old values. Visually, it should appear seamless. Kinda like:

 

area.attach(mc, {scaleMode:ScaleMode.STRETCH});
var originalTransforms:Matrix = mc.transform.matrix; //contains all the transform data
area.attach(mc, {scaleMode:ScaleMode.HEIGHT_ONLY});
TweenLite.to(mc, 2, {x:mc.x, y:mc.y, width:mc.width, height:mc.height, onComplete:area.attach, onCompleteParams:[mc, {scaleMode:ScaleMode.HEIGHT_ONLY}]});
area.release(mc);
mc.transform.matrix = originalTransforms;

 

The only thing to keep in mind is that the code assumes the LiquidArea won't resize/reposition during the tween. That'd make it much more complex. But hopefully this gives you a nudge in the right direction.

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×