Skip to main content
Known Participant
January 22, 2007
Answered

Flash button problem

  • January 22, 2007
  • 2 replies
  • 483 views
Hi
I am quite new to actionscript but when building a simple app that calculates amounts when you press on a button it only works if I use a library button and not my customised one. I have checked that the button is a button symbol and has four states but whenever I use my own customised button I get error message...the library button works fine with the actionscript.

Here is the error message I get with my custom button - any idea why?

thanks
Em

---------------------
**Error** Scene=Scene 1, layer=buttons, frame=1:Line 2: Invalid mouse event specified.
on(click) {

**Error** Scene=Scene 1, layer=buttons, frame=1:Line 3: Statement must appear within on handler
with(_parent){

**Error** Scene=Scene 1, layer=buttons, frame=1:Line 6: Unexpected '}' encountered
}

Total ActionScript Errors: 3 Reported Errors: 3
This topic has been closed for replies.
Correct answer MotionMaker
If you are designing your own button say using a MovieClip there are some different approaches.

One is to use the onRelease, onPress, onRollOver, etc MovieClip class methods to respond to events and you then gotoAndPlay or gotoAndStop at various frames on your Movieclip to show that state.

Thus you use clipInstanceName_mc.onRelease = function(){//The code};


Another is to attach a Class to the MovieClip symbol in the library under properties. In the class you can deploy the EventListener and Dispatcher classes under Components so that instantiations of the class can register as listeners. In this case you can call the events whatever you please. Inside the class, you respond to a set of the MovieClip methods (onRelease, onPress, etc) but dispatch them as you see fit which if you want could be a 'click' event.

Some sample code for latter:

2 replies

Participating Frequently
January 22, 2007
P.S. there is no click for Button Symbols.
Known Participant
January 22, 2007
Hi thanks

I understand the difference btw buttons now and that explains why it would not work...but am still unsure as to how I could customise this?

many thanks
Em


MotionMakerCorrect answer
Participating Frequently
January 22, 2007
If you are designing your own button say using a MovieClip there are some different approaches.

One is to use the onRelease, onPress, onRollOver, etc MovieClip class methods to respond to events and you then gotoAndPlay or gotoAndStop at various frames on your Movieclip to show that state.

Thus you use clipInstanceName_mc.onRelease = function(){//The code};


Another is to attach a Class to the MovieClip symbol in the library under properties. In the class you can deploy the EventListener and Dispatcher classes under Components so that instantiations of the class can register as listeners. In this case you can call the events whatever you please. Inside the class, you respond to a set of the MovieClip methods (onRelease, onPress, etc) but dispatch them as you see fit which if you want could be a 'click' event.

Some sample code for latter:
Participating Frequently
January 22, 2007
Know the type of button:
1. Button Symbols made in library:
on (press)
on (release)
on (rollOver)

This appears the one you are deploying.

See http://livedocs.macromedia.com/flash/8/main/00001752.html

2. The Flash Button Component:
... where there is a click event handler
http://livedocs.macromedia.com/flash/8/main/00003114.html

3. Custom buttons created with a MovieClip Symbol.
Use Actionscript and the methods for responding to events for example onRelease - http://livedocs.macromedia.com/flash/8/main/00002499.html