View Full Version : How to link a button to another frame in Flash CS3?

04-28-2008, 06:25 AM
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...

1 stop();
3 on (release) {
4 gotoAndPlay(155);
5 }
The error the program keeps outputting is

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.

04-28-2008, 07:43 AM
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.

04-28-2008, 08:28 AM
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".

04-28-2008, 04:25 PM
Then your button might not be a button. Is it a movieclip?

04-28-2008, 04:49 PM
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.
http://i26.photobucket.com/albums/c145/FlyingPenguins/th_flash.jpg (http://i26.photobucket.com/albums/c145/FlyingPenguins/flash.jpg)

04-28-2008, 09:15 PM
Check your publish settings. It might be on AS3, and not AS2. This code wouldn't work in AS3. It should be right otherwise.

04-29-2008, 06:30 AM
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
on (release) ; code back in. But even then, the movie outputs errors:

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?

04-29-2008, 08:22 AM
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!

buttonname.onRelease = function(){

04-29-2008, 07:48 PM
The stop() action needs to be on the frame; the on(release) function goes on the button.

05-01-2008, 06:43 AM
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
stop();, then single-clicked the button and entered

on (release) {
} and it worked!

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. :rolleyes: 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. :thumbsup:

05-01-2008, 07:47 AM
Clicking once meant one click. Its something that confused me at first too, but glad you figured it out!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum