Skip to main content
Participant
December 11, 2008
Question

Flash 8 Actionscript Tutorial problem

  • December 11, 2008
  • 3 replies
  • 483 views


I have followed the following instructions to the letter (several times) but the button script won't activate a URL and I get an error message from Flash 8 which I'll show after this:

1.Select the invisible button on the Stage.
Open the Property inspector (Window > Properties), and find the Instance Name text box in the Property inspector.
Type inv_btn into the Instance Name text box.

Select Insert > Timeline > Layer to insert a new layer, and then rename the new layer to actions.
Open the Actions panel (Window > Actions), and then select Frame 1 of the actions layer.
Type the following ActionScript into the script pane (the editable text field) in the Actions panel:

inv_btn.onRelease = function(){
getURL(" http://gnome.deseloper.com", "_blank");
};

This does not work. Here is the error message:
**Error** Scene=Scene 1, layer=button, frame=1:Line 1: Statement must appear within on handler
inv_btn.onRelease = function(){

As this script was copied directly from the tutorial text, and I have never scripted anything before, I am at a loss to explain this or how to make it work. Can anyone help me?

This topic has been closed for replies.

3 replies

jimcarr5Author
Participant
December 12, 2008
Oh NEVER MIND! I applied my old code in the same way and it works. You solved my problem!

Thanks so much for being there. Learning this stuff would be much harder without the support of people like you.
jimcarr5Author
Participant
December 12, 2008
Here's what I got when I applied your script to frame 1 on the Actions layer:

**Error** Scene=Scene 1, layer=actions, frame=1:Line 1: Mouse events are permitted only for button instances
on(release){

Total ActionScript Errors: 1 Reported Errors: 1

What does this tell us?
Ned Murphy
Legend
December 11, 2008
I'll approach this from the opposite end... replace the code you have with:

on(release){
getURL(" http://gnome.deseloper.com", "_blank");
}

If that works, then the problem is that you didn't put the code where the instructions you show indicated you should. For what you did, the code I just showed is appropriate (though not a good practice because it is hidden from easy review). It's better to keep your code in the timeline where it can be easily found.

You will have selected the button and then typed the code in the actionscript editor. Instead, you need to click on the frame in the (separate) actions layer in the main timeline that you should have made already, not the button layer, and then place that code from the tutorial in the actionscript editor window.