View Full Version : Mouse event errors
Hi,
I've just finished making a little banner for my site, but i forgot to add button in it. As i try to add button to the animation i get this message:
**Error** Scene=Scene 1, layer=button, frame=1:Line 1: Mouse events are permitted only for button instances
on (release) {
Total ActionScript Errors: 1 Reported Errors: 1
Im new to actionscript and i can't find whats the problem :/
Please help !!! I attached my work below.
Welcome aboard,
on(release) code needs to be placed directly on the symbol you want to trigger the event. You are receiving that error message becuase you are trying to place that script on the timeline.
If you wanted to place it on the timeline (which is a better practice, btw) you need to format it into a function, give the button an instance name, and reference that in the script:
this.myButton.onRelease=function(){
getURL("http://www.nga-gaming.com", "_blank");
}
(Where the instance name of your button is "myButton")
Ok, so i've created a new blank layer and placed a code in timeline. But it has no effect because it doesn't act as a button. Btw, how do i give blank layer instance name!?
Plus i get this error message:
**Error** Scene=Scene 1, layer=button, frame=1:Line 1: Statement must appear within on handler
this.Button.onRelease=function(){ getURL("http://www.nga-gaming.com", "_blank"); }
WARNING: This movie uses features that are not supported in the Flash 5 player
Scene=Scene 1, layer=button, frame=1:Flash MX Button Instance Name
Total ActionScript Errors: 1 Reported Errors: 1
Fndz,
Read some tutorials man, you need to understand some basic concepts before you start trying to write code.
Check out:
kirupa.com, flashkit.com, here, google, etc...
You can't give a layer an instance name, layers don't exist once the file is published...
I told you to place the script on a blank layer becuase you kept putting it on the object itself. Putting it in a blank layer just assures that the script is on the timeline and not on an object.
You need to give your button symbol an instance name, and then use that name when you write the code.
in the code above, the instance name of the button is "Button", so you would have to be sure that was the name you had on it.
Besides, if you get the error:
"Statement must appear within on handler"
You did NOT put it on the timeline in an empty layer, you placed it on a symbol...
I would just insert the code correctly into your file, but if you are using Flash 5, you couldn't open it anways. I use Flash 8, which only allows you to save as Flash8, or Flash MX.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.