i'm attempting (so far unsuccessfully) to programatically increase and decrease the scale of an object on stage. there is a Grow button (grow_btn) and a Shrink button (shrink_btn), which increase and decrease the scaleX and scaleY properties of a selected object (either redObject, greenObject or blueObject) over time.
the problem i'm encountering seems random, where sometimes only one of the properties (either scaleX or scaleY) will change while the other does not. additionally, the target and original sizes for the tween functions don't adjust correctly. For example: 1.0 is nearly twice as large as the object onstage.
//Imports
import fl.transitions.Tween;
import fl.transitions.easing.*;
//Constants And Variables
const starRotationAngle:Number = 0.5;
const starSpeed:Number = 2;
var moveForward:Boolean = true;
var selectedObject:MovieClip;
//Event Listeners & Functions
star_mc.addEventListener(MouseEvent.CLICK, rotateStar);
function rotateStar(e:MouseEvent):void
{
star_mc.rotation += 5;
}
addEventListener(Event.ENTER_FRAME, starMove);
function starMove(e:Event):void
{
if (star_mc.x >= stage.stageWidth + star_mc.width)
{moveForward = false;}
else if (star_mc.x <= stage.x - star_mc.width)
{moveForward = true;}
if (moveForward == true)
{
star_mc.x += starSpeed;
star_mc.rotation += starRotationAngle;
}
else
{
star_mc.x -= starSpeed;
star_mc.rotation -= starRotationAngle;
}
}
redObject.addEventListener(MouseEvent.CLICK, changeSelectedObjectVariable);
greenObject.addEventListener(MouseEvent.CLICK, changeSelectedObjectVariable);
blueObject.addEventListener(MouseEvent.CLICK, changeSelectedObjectVariable);
function changeSelectedObjectVariable(e:MouseEvent):void
{
selectedObject = e.currentTarget as MovieClip;
}
grow_btn.addEventListener(MouseEvent.CLICK, grow);
function grow(e:MouseEvent):void
{
var tweenGrowX:Tween = new Tween(selectedObject, "scaleX", None.easeIn, 1.0, 2.0, 3.0, true);
var tweenGrowY:Tween = new Tween(selectedObject, "scaleY", None.easeIn, 1.0, 2.0, 3.0, true);
}
shrink_btn.addEventListener(MouseEvent.CLICK, shrink);
function shrink(e:MouseEvent):void
{
var tweenShrinkX:Tween = new Tween(selectedObject, "scaleX", None.easeIn, 2.0, 1.0, 3.0, true);
var tweenShrinkY:Tween = new Tween(selectedObject, "scaleY", None.easeIn, 2.0, 1.0, 3.0, true);
}