Be a Supporter!

Buttons and gotoAndStop()?

  • 241 Views
  • 4 Replies
New Topic Respond to this Topic
mcgyvr2009i
mcgyvr2009i
  • Member since: Dec. 23, 2010
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Buttons and gotoAndStop()? Jan. 31st, 2013 @ 09:44 AM Reply

Hi. I can't for the LIFE of me, figure out how to program a button in AS3 OR 2 so that when you click on it, it goes to the next frame(Only in my case, frame 81). I have tried hundreds of thousands of different codes in both ActionScript 3 and 2. I give up. I need a little help here. I tried looking at numerous tutorials, but NONE of them worked. Here's the final attempt that failed:

ActionScript 3.0

import flash.display.SimpleButton;
import flash.display.MovieClip;
import flash.events.MouseEvent;
stop();
var newGame:SimpleButton = new SimpleButton();
newGame.addEventListener(MouseEvent.MOUSE_DOWN, startNewGame);
function startNewGame(e:MouseEvent):void
{
	nextFrame();
}

ActionScript 2.0

onEnterFrame(MouseEvent.CLICK)
{
gotoAndStop(81);
}

I can't keep doing this. It's frustrating me too severely. If I keep trying I'm only going to have a heart attack. So, if you can help me out here, that would be great.


Thanks in advance.
Ian Hulett

milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to Buttons and gotoAndStop()? Jan. 31st, 2013 @ 11:10 AM Reply

At 1/31/13 09:44 AM, mcgyvr2009i wrote: Hi. I can't for the LIFE of me, figure out how to program a button in AS3 OR 2 so that when you click on it, it goes to the next frame(Only in my case, frame 81).

What should go to frame 81? If it'S your button, you have to call the gotoAndStop method on that

nextFrame();

This will not necessarily go to frame 81, but the next one.

mcgyvr2009i
mcgyvr2009i
  • Member since: Dec. 23, 2010
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Buttons and gotoAndStop()? Jan. 31st, 2013 @ 05:19 PM Reply

At 1/31/13 11:10 AM, milchreis wrote:
At 1/31/13 09:44 AM, mcgyvr2009i wrote: Hi. I can't for the LIFE of me, figure out how to program a button in AS3 OR 2 so that when you click on it, it goes to the next frame(Only in my case, frame 81).
What should go to frame 81? If it'S your button, you have to call the gotoAndStop method on that

nextFrame();
This will not necessarily go to frame 81, but the next one.

Well, I don't want any specific object to proceed. I want the screen to go from the title screen to an opening cut scene, and then after that, to the first room. The project stops at frame 80 with the

stop();

function, and from 81 on is the opening cut scene. But the button refuses to work for me.


Thanks in advance.
Ian Hulett

mcgyvr2009i
mcgyvr2009i
  • Member since: Dec. 23, 2010
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Buttons and gotoAndStop()? Jan. 31st, 2013 @ 05:21 PM Reply

At 1/31/13 11:10 AM, milchreis wrote:
At 1/31/13 09:44 AM, mcgyvr2009i wrote: Hi. I can't for the LIFE of me, figure out how to program a button in AS3 OR 2 so that when you click on it, it goes to the next frame(Only in my case, frame 81).
What should go to frame 81? If it'S your button, you have to call the gotoAndStop method on that

nextFrame();
This will not necessarily go to frame 81, but the next one.

Well, I don't want any specific object to proceed. I want the screen to go from the title screen to an opening cut scene, and then after that, to the first room. The project stops at frame 80 with the

stop();

function, and from 81 on is the opening cut scene. But the button refuses to work for me.


Thanks in advance.
Ian Hulett

milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to Buttons and gotoAndStop()? Jan. 31st, 2013 @ 05:43 PM Reply

At 1/31/13 05:21 PM, mcgyvr2009i wrote: But the button refuses to work for me.

Which is empty and never added to the screen:

var newGame:SimpleButton = new SimpleButton();

You create a new object here that floats around in memory but is never displayed.
If you have the button on the stage already, there's no need to create a new object.