A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] flash cs3 timeline control code help

  1. #1
    Senior Member sybershot's Avatar
    Join Date
    Nov 2007
    Posts
    164

    resolved [RESOLVED] flash cs3 timeline control code help

    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");

    }

  2. #2

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    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.
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Senior Member sybershot's Avatar
    Join Date
    Nov 2007
    Posts
    164
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center