PDA

View Full Version : Help on game menu



von_dragon
April 20th, 2004, 07:59 PM
Okay, i need help.

For some reason i cant get my flash to assign an action to a button. I want to make a game menu but i cant assign actions to the buttonss. It says

**Error** Scene=Scene 1, layer=main menu, frame=49:Line 1: Statement must appear within on handler
gotoAndStop(58);

how come it wont work?

pom
April 21st, 2004, 05:38 AM
Well, Flash tells you why it's not working: the statement must appear within on handler :)

Buttons in Flash are objects that will run a piece of code when you do something with them, they will never do something by themselves. You can press them, roll over them, release them, roll out... So you have to specify which particular event you're tracking in your code with the 'on' event handler:
on (press) {
// run this code when the user releases the button
trace ("Button Pressed") ;
}
on (release) {
// run this code when the user presses the button
trace ("Button Released") ;
}
on (rollOver) {
// run this code when the user rolls over the button
trace ("Button Rolled Over") ;
}And so on and so forth :)

von_dragon
April 21st, 2004, 03:34 PM
where should i put this code..? In the button or in the frame and do i put the whole thing. i Tried that but maybe i did sumthing wrong but i want it to go to that part of the menu but it wont....

tofu
April 22nd, 2004, 03:07 AM
put it in the button

on(release){
gotoAndStop(58);
}

pom
April 22nd, 2004, 11:53 AM
on (press) kind of actions go on the buttons.
myButton.onPress = function () {} go on the frame.

tofu
April 22nd, 2004, 10:26 PM
Ilyas knows the drill.