Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to link a button to another frame in Flash CS3?

    Hi, I'm trying to make a button in Flash CS3 that links to another part of my movie. The movie stops at the frame with the button on it (frame 145), and one must click on it to continue to frame 155. No matter what I do, it outputs an error and while testing, the frame with the button shows for a split-second before continuing to the rest of the movie without stopping.

    Here's the code. I'm trying to make it as simple as possible...
    Code:
    1  stop();
    2  
    3  on (release) {
    4  gotoAndPlay(155);
    5  }
    The error the program keeps outputting is
    Code:
    Scene 1, Layer 'Tile_Button', Frame 145, Line 3
    1087: Syntax error: extra characters found after end of program.
    Removing the brackets results in even more errors.

    Any ideas on how to fix this? Thanks in advance.
    Last edited by FlyingPenguins; 04-28-2008 at 07:15 AM.

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    The on (release) and so on code needs to be placed on the button itself, not in the frame.

    There is nothing wrong with the syntax, just placed on the wrong element. Just click on the button once, open the actions panel and paste the on release code there.

  • Users who have thanked gnomeontherun for this post:

    FlyingPenguins (04-28-2008)

  • #3
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your reply. I can't seem to get what you said to work though - keeps saying "current action cannot have actions applied to it".

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Then your button might not be a button. Is it a movieclip?

  • #5
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm pretty sure it is a button.

    Here's a screenshot of me trying to apply actions to the button, click to enlarge. The name of the button is in the library (not "returnbutton"), but when I try to edit the Start Movie one, it shows up/down/hover etc.

  • #6
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Check your publish settings. It might be on AS3, and not AS2. This code wouldn't work in AS3. It should be right otherwise.

  • #7
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok, I found out how to change the version of ActionScript used in the movie, so it is now 2.0. I put the old
    Code:
    on (release) ;
    code back in. But even then, the movie outputs errors:
    Code:
    Description: Mouse events are permitted only for button instances
    Source: on (release.StartButton) {
    I tried putting the code in both my Button's layer and Actions layer, with no success.

    However, this time it may be just because I don't understand ActionScript well. Do I have to include additional lines of code, for example, functions?

  • #8
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Ok better idea try this code on the frame with the stop(); You will need to give the button an instance name, and then change 'buttonname' to that same name. on (release) doesn't work in this situation, I get confused as well sometimes!

    Code:
    buttonname.onRelease = function(){
       gotoAndPlay(115);
    };
    Last edited by gnomeontherun; 04-29-2008 at 08:22 AM. Reason: add code brackets

  • #9
    Regular Coder
    Join Date
    Aug 2002
    Location
    San Francisco
    Posts
    455
    Thanks
    19
    Thanked 15 Times in 15 Posts
    The stop() action needs to be on the frame; the on(release) function goes on the button.
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read. Groucho Marx

  • #10
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok, my teacher (yes, this was part of a class project) discovered what I did wrong, after being confused himself. When I tried to edit the actions of the button I always double-clicked the button, opening the Up/Over/Down/Hit layer menu. What I was supposed to do was to single-click it.

    So I clicked the keyframe in the layer menu and added the
    Code:
    stop();
    , then single-clicked the button and entered
    Code:
    on (release) {
    	gotoAndPlay(155);
    }
    and it worked!

    Quote Originally Posted by jeremywilken View Post
    Just click on the button once, open the actions panel and paste the on release code there.
    I think I may have misread that the first time I saw it. Kept on thinking clicking the button once meant double-clicking. But I'm not sure if I actually did try doing that when the movie was still set to AS3, but it didn't work.

    Well anyways, thanks jeremywilken and marilynn.fowler for replying.

  • #11
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Clicking once meant one click. Its something that confused me at first too, but glad you figured it out!


  •  

    Posting Permissions

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