Hi, I have the following long and repetitive AS3 code just for 3 buttons and I need to add more buttons. Since it is not the right way, I seek help from experts to help me in using If condition to shorten the code.
stop();
import com.greensock.;
import com.greensock.easing.;
P01.addEventListener(MouseEvent.CLICK, P01btnClick);
P02.addEventListener(MouseEvent.CLICK, P02btnClick);
P03.addEventListener(MouseEvent.CLICK, P03btnClick);
function P01btnClick(event:MouseEvent):void {
TweenLite.to(Page01, 1, {x:0, y:0, delay:0, ease:Circ.easeOut});
TweenLite.to(Page00, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
TweenLite.to(Page02, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
TweenLite.to(Page03, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
}
function P02btnClick(event:MouseEvent):void {
TweenLite.to(Page02, 1, {x:0, y:0, delay:0, ease:Circ.easeOut});
TweenLite.to(Page00, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
TweenLite.to(Page01, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
TweenLite.to(Page03, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
}
function P03btnClick(event:MouseEvent):void {
TweenLite.to(Page03, 1, {x:0, y:0, delay:0, ease:Circ.easeOut});
TweenLite.to(Page00, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
TweenLite.to(Page01, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
TweenLite.to(Page02, 1, {x:0, y:800, delay:0, ease:Circ.easeOut});
}