;

PDA

Click to See Complete Forum and Search --> : [RESOLVED] flash cs3 timeline control code help


sybershot
11-25-2007, 04:32 AM
would be appreciative if some one can help me with this please
i'm trying to use 7 buttons to go to 7 different frames I tried all
sorts of combinations

if I use only one button and code this it work great
stop();
btn1.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
gotoAndStop("62");

}

But if I use this I get scipt errors

stop();
btn1.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
gotoAndStop("62");

}

btn2.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
gotoAndStop("63");

}

btn3.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
gotoAndStop("64");

}

btn4.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
gotoAndStop("65");

}

btn5.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
gotoAndStop("66");

}

btn6.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
gotoAndStop("67");

}

btn7.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
gotoAndStop("68");

}

whispers
11-25-2007, 09:26 AM
move to Flash CS3 & AS3 forum...

cancerinform
11-25-2007, 09:46 AM
You can do two things:

1. You need to give every function a unique name (buttonClickHandler1, etc).
2. To avoid writing 7 different functions you can pass parameters. If your buttons are MovieClips an easy way is to write:

btn1.frameName = "62";
btn1.addEventListener (MouseEvent.CLICK, buttonClickHandler);
btn2.frameName = "37";
btn2.addEventListener (MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler (event:MouseEvent):void
{
gotoAndStop(event.currentTarget.frameName);
}

There are other ways to pass parameters, which are a bit more complicated. You can find them by searching this forum.

sybershot
11-25-2007, 12:40 PM
Thank you very much. I will try that today.
I guess do to me being fairly new I did not search for the propper terms. Ive been searching for 2and 1/2 days under timeline control, and buttons. Again thank you so very much. sincerly sybershot