-
Simplify code
Hello,
how can i simplify this code:
PHP Code:
stop();
import com.greensock.*;
import com.greensock.easing.*;
import flash.events.MouseEvent;
var timeline:TimelineMax= new TimelineMax({paused:true});
var timeline1:TimelineMax= new TimelineMax({paused:true});
var timeline2:TimelineMax= new TimelineMax({paused:true});
timeline.append(TweenMax.to(alfa,3, {y:150, alpha:1, ease:Elastic.easeInOut}));
timeline1.append(TweenMax.to(beta,3, {y:200, alpha:1, ease:Elastic.easeInOut}));
timeline2.append(TweenMax.to(teta,3, {y:200, alpha:1, ease:Elastic.easeInOut}));
boton.addEventListener(MouseEvent.CLICK, prueba);
function prueba(e:MouseEvent):void{
timeline2.reverse();
timeline1.reverse();
timeline.play();
}
boton1.addEventListener(MouseEvent.CLICK, prueba1);
function prueba1(e:MouseEvent):void{
timeline.reverse();
timeline2.reverse();
timeline1.play();
}
boton2.addEventListener(MouseEvent.CLICK, prueba2);
function prueba2(e:MouseEvent):void{
timeline.reverse();
timeline1.reverse();
timeline2.play();
}
I think, for loop can be used but i don't know how
Thanks for your help
-
Code:
stop();
import com.greensock.*;
import com.greensock.easing.*;
import flash.events.MouseEvent;
var currBtn:DisplayObject;
var btnArray:Array = [[boton, alfa, 150], [boton1, beta, 200], [boton2, teta, 200], ];
btnArray.map(makeIt);
function makeIt(element:*, index:int, arr:Array):void {
var timeline:TimelineMax=new TimelineMax({paused:true});
timeline.append(TweenMax.to(element[1], 3, {y:element[2], alpha:1, ease:Elastic.easeInOut}));
element.push(timeline);
element[0].addEventListener(MouseEvent.CLICK, setCurrBtn);
}
function setCurrBtn(e:MouseEvent):void {
currBtn=e.currentTarget as DisplayObject;
btnArray.map(doTimelines);
}
function doTimelines(element:*, index:int, arr:Array):void {
if (element[0]==currBtn) {
element[3].play();
} else {
element[3].reverse();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|