Jump to content
Search Community

AutoFitArea and Tweenlite

Asteroids test
Moderator Tag

Recommended Posts

You can tween the size of the AutoFitArea with an ease and the object attached to it will change its size automatically with the same ease defined.

 

AutoFitArea is configured so that any changes to its size get translated to its contents.

 

Create an fla with a symbol with instance name myImage and add this code:

 

 

//import the GreenSock classes
import com.greensock.layout.*;
import com.greensock.*;
import com.greensock.easing.*;


//create a 300x100 rectangular area at x:50, y:70 that stretches when the stage resizes (as though its top left and bottom right corners are pinned to their corresponding PinPoints on the stage)
var area:AutoFitArea = new AutoFitArea(this, 50, 70, 300, 100, 0xCC0000);


//attach a "myImage" Sprite to the area and set its ScaleMode to PROPORTIONAL_OUTSIDE and crop the overspill
area.attach(myImage, {scaleMode:ScaleMode.PROPORTIONAL_INSIDE, crop:true});


//if you'd like to preview the area visually, set preview to true (by default previewColor is red)
area.preview = true;
  
//attach a CHANGE event listener to the area
area.addEventListener(Event.CHANGE, onAreaUpdate);
function onAreaUpdate(event:Event):void {
    //trace("updated AutoFitArea");
}


//tween the size of the autoFitArea
TweenLite.to(area, 1, {width:400, height:400, ease:Bounce.easeOut, delay:1});
Link to comment
Share on other sites

your example is 2kb file that after I extracted it had a .cpgz extension. I have no idea what that is. Perhaps something got corrupted. Please try again.

 

Unfortunately due to the language barrier I am having a very difficult time understanding what you want to accomplish. 

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...