Jump to content


Simple tweening question

Recommended Posts

I was hoping someone could help me out. This should be really simple and I cant figure it out.

So I have an ad that I am working on. Its 300x250 and it expands to lets say 560.

I have a mask thats 300x250 and I want to animate that open to the length of 560

and when the user clicks the close button it needs to go back to 300. Ive done it before

and today I cant get it to work.


What's happening in my code is the mask animates to the right and never stops. If I pull

the window open the mask opens infinately.


This is my code and I have attached a simple file with my code inside if thats easier

Thanks ahead of time for the help.


import flash.events.MouseEvent;

import com.greensock.*;
import com.greensock.easing.*;

Open.addEventListener(MouseEvent.CLICK, OpenNow)
function OpenNow(e:MouseEvent):void{
TweenLite.to(Mask,2,{scaleX:560, ease:Expo.easeIn});

Close.addEventListener(MouseEvent.CLICK, CloseNow)
function CloseNow(e:MouseEvent):void{
TweenLite.to(Mask,2,{scaleX:0, ease:Expo.easeIn});

Link to comment
Share on other sites

you want to use width instead of scaleX.


width is an exact pixel value

scaleX is a percentage where 1 is 100% and .5 would be 50%.

Link to comment
Share on other sites

How would I specify the exact distance then?

I want to go about 40 pixels out from my 300 pixel box and then back

Link to comment
Share on other sites

to answer your original question more clearly:


to change its size adjust the width via:


TweenLite.to(Mask,2,{width:560, ease:Expo.easeIn});


I want to go about 40 pixels out from my 300 pixel box and then back


I really don't know what you are asking. are you moving something? or making it stretch?


i have to assume you are moving something as the size issue has been addressed.


this will move the mask to an x value of 40

TweenLite.to(Mask,2,{x:40, ease:Expo.easeIn});


this will move the mask 40 pixels to the right of its original position

TweenLite.to(Mask,2,{x:"40", ease:Expo.easeIn});


note the use of quotes around "40". that means it is a relative value


if you want to repeat a tween use TweenMax


TweenMax.to(Mask,2,{x:40, ease:Expo.easeIn, repeat:1, yoyo:true});


Take a look at the TweenMax page http://www.greensock.com/tweenmax/ it gives examples and descriptions of all these concepts and features.

Link to comment
Share on other sites

Hi Carl,


Thanks for getting back to me so quick.

In a nutshell I am stretching a mask.


I was using: ScaleX when I should have been using Width as you pointed out.

Thanks so much for your 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.