PDA

View Full Version : button help



bladeswim83
August 25th, 2008, 02:05 PM
Hello,
i think this should be easy but I can't figure it out.
I doing this presentation and my client wants 4 buttons lined up on the left and when you click one of these buttons an arrow goes and point to another word on the right. Now I can do that on the time line and have each button use the AS
on (release) {
gotoAndPlay(160);
}

and assign each button to a certain point on the timeline but if they have the 4th button pushed and for some reason they want to push the 1st button they don't want the ending animation of buttons 2-4 to go away.

How can i make a button have it do something and stay on there? If this makes no sense let me know.

Anil_kumar
August 26th, 2008, 07:28 AM
i think its solved :-)

it uses AS3


import fl.transitions.Tween;
import fl.transitions.easing.*;

var MyRoot = root;
var i:int;
for (i = 1; i<=2; i++) {
MyRoot["head_"+i].alpha=0;
}
for (i = 1; i<=4; i++) {
MyRoot["btn_"+i].alpha=0;
}
for (i = 1; i<=4; i++) {
MyRoot["arrow_"+i].alpha=0;
MyRoot["arrow_"+i].id=0;
}
for (i = 1; i<=4; i++) {
MyRoot["target_"+i].alpha=0;
}
//you can change fps here
stage.frameRate=30;


var MyTimer = new Timer(1000,6);
MyTimer.addEventListener(TimerEvent.TIMER,FirstAni mation);
MyTimer.start();
var j:int =1;
function FirstAnimation(e:TimerEvent):void {
if (j==1) {
TweenFunction(head_1,"alpha",0,1,1);
TweenFunction(head_1,"y",head_1.y-5,head_1.y+5,1);
j++;
} else if (j>=2&&j<=5) {
TweenFunction(MyRoot["btn_"+String(j-1)],"alpha",0,1,1);
TweenFunction(MyRoot["btn_"+String(j-1)],"x",(MyRoot["btn_"+String(j-1)].x)-5,(MyRoot["btn_"+String(j-1)].x)+5,1);
j++;
} else {
TweenFunction(head_2,"alpha",0,1,1);
TweenFunction(head_2,"y",head_2.y-5,head_2.y+5,1);
}
}

function TweenFunction(MyObject:MovieClip,properti:String,s taart:int,end:int,speed:Number):void {
var MyTween:Tween = new Tween(MyObject, properti, Regular.easeIn, staart, end, speed, true);
}

for (var k:int =1; k<=4; k++) {
MyRoot["btn_" + k].addEventListener(MouseEvent.CLICK,ClickHandler);
MyRoot["btn_" + k].id=k;
}

function ClickHandler(e:MouseEvent) {
if (MyRoot["arrow_"+e.target.id].id==0) {
TweenFunction(MyRoot["arrow_"+e.target.id],"alpha",0,1,1);
TweenFunction(MyRoot["arrow_"+e.target.id],"x",159,169,1);
TweenFunction(MyRoot["target_"+e.target.id],"alpha",0,1,2);
MyRoot["arrow_"+e.target.id].id=1;
}
}

Anil
anilkumarnd@gmail.com