I have a container of images I would move:
private var mainContainer:MovieClip = new MovieClip;
private var mainMovement:TweenMax;
public function moveTest() {
...
for each(var item:XML in xmlData.BANNERS.ITEM) {
bannerArray[index] = new Image(item.toString(), index);
IMAGE_WIDTH = bannerArray[index].width;
IMAGE_HEIGHT = bannerArray[index].height;
bannerArray[index].x = index * IMAGE_WIDTH + index * PADDING_IMAGE;
mainContainer.addChild(bannerArray[index]);
index++;
}
var _space:Number = mainContainer.width - STAGE.stageWidth;
_time = _space / _speed;
mainMovement = new TweenMax(mainContainer, _time, { x:STAGE.stageWidth-mainContainer.width, ease:None.easeNone, paused:true } );
private function setupArrows():void {
var areaLeft:MovieClip = new MovieClip;
with (areaLeft) {
graphics.beginFill(0xFFFFFF, 0);
graphics.drawRect(0, 0, 70, 10);
graphics.endFill();
buttonMode = true;
addEventListener(MouseEvent.ROLL_OVER, onLeftRollover);
addEventListener(MouseEvent.ROLL_OUT, onLeftRollout);
}
addChild(areaLeft);
var areaRight:MovieClip = new MovieClip;
with (areaRight) {
graphics.beginFill(0xFFFFFF, 0);
graphics.drawRect(0, 0, 70, 10);
graphics.endFill();
buttonMode = true;
addEventListener(MouseEvent.ROLL_OVER, onRightRollover);
addEventListener(MouseEvent.ROLL_OUT, onRightRollout);
}
addChild(areaRight);
}
private function onLeftRollover(e:MouseEvent):void {
mainMovement.reverse();
}
private function onLeftRollout(e:MouseEvent):void {
mainMovement.pause();
}
private function onRightRollover(e:MouseEvent):void {
mainMovement.reversed = false;
mainMovement.resume();
}
private function onRightRollout(e:MouseEvent):void {
mainMovement.pause();
var arrive:Number = (Math.floor( -mainContainer.x / (IMAGE_WIDTH + PADDING_IMAGE)) + 1) * (IMAGE_WIDTH + PADDING_IMAGE);
TweenLite.to(mainContainer, _duration, { x: -arrive } );
}
}
I'm not trying to tween another tween's properties, I would to update a properties of an existing tween after a "manual" movement of its target... I could have written even something like this:
private function onRightRollout(e:MouseEvent):void {
mainMovement.pause();
var arrive:Number = (Math.floor( -mainContainer.x / (IMAGE_WIDTH + PADDING_IMAGE)) + 1) * (IMAGE_WIDTH + PADDING_IMAGE);
mainContainer.x = -arrive;
}