PDA

View Full Version : Everything but e.currentTarget



J_Mo
February 17th, 2010, 06:10 AM
Hi,

I have a function which triggers a tween for the currentTarget in an array when target is clicked but how can I trigger a tween for everything else in the array??


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

var clipsArray:Array=new Array(mc1,mc2,mc3,mc4,mc5,mc6);
trace(clipsArray);

var clipsMargin:Number=1;

function updatePosition():void {
for (var i:uint = 0; i<=5; i++) {
if (i==0) {
clipsArray[i].y=100;
} else {

clipsArray[i].y=clipsArray[i-1].y+clipsArray[i-1].height+clipsMargin;
}
clipsArray[i].addEventListener(MouseEvent.CLICK, setTweenClick);
/*clipsArray[i].addEventListener(MouseEvent.ROLL_OUT, setTweenOut);*/
}
}

updatePosition();

function setTweenClick(e:MouseEvent):void {
TweenLite.to(e.currentTarget, 0.1, { scaleX:1.4, scaleY:1.4,ease:Circ.easeIn,onUpdate:updatePositio n});
TweenLite.to(EVERYTHING ELSE??, 0.1, { scaleX:1, scaleY:1,ease:Circ.easeIn});

}

Obviously, EVERYTHING ELSE means the other mc's in the array.

Phil

_kp
February 17th, 2010, 07:08 AM
Loop through the array.If an item is not currentTarget start a tween:



function setTweenClick(e:MouseEvent):void {
TweenLite.to( e.currentTarget, 0.1, { scaleX:1.4, scaleY:1.4,ease:Circ.easeIn,onUpdate:updatePositio n});
for(var i:int =0;i<clipsArray.length;i++){
if( clipsArray[i] != e.currentTarget ){
TweenLite.to( clipsArray[i] , 0.1, { scaleX:1, scaleY:1,ease:Circ.easeIn});
}
}
}

J_Mo
February 17th, 2010, 08:31 AM
Thanks, worked wonderfully.

I have a new problem now. I have and array of six MCs on the stage, when rolled over the currenTarget scales up, when rolled out it scales back to its original size. Both events are relative to the other mcs

When clicked its height and width increase to fit to the stage size but here is the problem...I cant get the currentTarget.y to 0, its increases to the right size but in the wrong position.

I believe the problem lies with a function I have for the positioning the arrays.

updatePosition()


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

var clipsArray:Array=new Array(mc1,mc2,mc3,mc4,mc5,mc6);
trace(clipsArray);

var clipsMargin:Number=1;

function updatePosition():void {
for (var i:uint = 0; i<=5; i++) {
if (i==0) {
clipsArray[i].y=100;
} else {

clipsArray[i].y=clipsArray[i-1].y+clipsArray[i-1].height+clipsMargin;
}
clipsArray[i].addEventListener(MouseEvent.ROLL_OVER, setTweenOver);
clipsArray[i].addEventListener(MouseEvent.ROLL_OUT, setTweenOut);
clipsArray[i].addEventListener(MouseEvent.CLICK, setTweenClick);
}
}

updatePosition();

function setTweenOver(e:MouseEvent):void {
TweenLite.to(e.currentTarget, 0.1, { scaleX:1.4, scaleY:1.4,ease:Circ.easeIn,onUpdate:updatePositio n});
/*for(var i:int =0;i<clipsArray.length;i++){
if( clipsArray[i] != e.currentTarget ){
TweenLite.to( clipsArray[i] , 0.1, { scaleX:1, scaleY:1,ease:Circ.easeIn});
}*/
}

function setTweenOut(e:MouseEvent):void {
TweenLite.to(e.currentTarget, 0.1, { scaleX:1, scaleY:1,ease:Circ.easeIn, onUpdate:updatePosition});
}


function setTweenClick(e:MouseEvent):void {
for (var i:int =0; i<clipsArray.length; i++) {
if (clipsArray[i]==0) {
TweenLite.to(e.currentTarget, 0.5, { height:stage.stageHeight, width:stage.stageWidth, y:0,ease:Circ.easeIn});
} else {
TweenLite.to(e.currentTarget, 0.5, { height:stage.stageHeight, width:stage.stageWidth, y:0,ease:Circ.easeIn,onUpdate:updatePosition});
}
}
}

I don't know what to do to correct the positioning.

Thanks
Phil