all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

Can someone PLEASE help me with buttons?


Can someone PLEASE help me with buttons? Spot2004
4/16/2005 12:00:00 AM
flash actionscript:
Everytime I make a regular button, place it in, place any ActionScript, it
gives me an error like:

**Error** Scene=Scene 1, layer=Layer 5, frame=1:Line 1: Statement must appear
within on handler
gotoAndPlay(1);

Total ActionScript Errors: 1 Reported Errors: 1

How do I get rid of it??

Also, I would like to know how to make buttons play sounds and such. I tried
looking at the help files and they never gave me any information that worked.
Re: Can someone PLEASE help me with buttons? pickle jar
4/16/2005 12:00:00 AM
Hi Spot2004, Can help u on the first Q. Cannot place AS
actually on a button (excludes button components) as far as I am aware. You
need to make your button, put it onto the main stage, give it an instance name
then create a new layer for as and reference it (using the instance name) there
i.e. myBtn.onRelease = function() { goToAndPlay(2); }
Re: Can someone PLEASE help me with buttons? pickle jar
4/16/2005 12:00:00 AM
sorry typo error, its:

Re: Can someone PLEASE help me with buttons? MikOne
4/16/2005 12:00:00 AM
You can place actionscript directly on a button, as follows
1)create button on stage
2)give it an instance name
3)open your "actions" panel where you enter action script and click on the
button on the stage
4)then type

this.onPress = function() {
gotoAndPlay(1);
}

alternatively you can place the script on a blank layer on the same frame
where your button is located

buttonInstanceName.onPress = function() {
gotoAndPlay(1);
}

Can't provide any sound info at the moment, sorry.
Hope this helps.
Re: Can someone PLEASE help me with buttons? lookche
4/16/2005 12:00:00 AM
For the button put this code on the actual button:
on (release) {
gotoAndPlay(2);
}
There is no need for any instance names and stuff with that command ;)

And for the sound (assuming you would want it to play from the library):
on (release) {
_global.Behaviors.Sound.instance.start(0,1); //where instance is the linkage
ID you exported it for
}

I hoped i could help you, good luck with your MP3 Player
Lucas
AddThis Social Bookmark Button