Be a Supporter!

stop(); Not Working?!?

  • 350 Views
  • 14 Replies
New Topic Respond to this Topic
Kwing
Kwing
  • Member since: Jul. 24, 2007
  • Online!
Forum Stats
Member
Level 45
Game Developer
stop(); Not Working?!? 2009-02-21 20:49:30 Reply

Guys, I think I'm going crazy. My stop action won't work. You heard right, and no, I'm not a noob. I honestly think this is Flash's fault but I really, really hope I'm wrong. Facts:
>>> The problem itself is that the Movie Clip won't stop. It just plays through, but stops at the end, which is weird because there isn't even a stop action at the end.
>>> I'm using Flash 8 and ActionScript 2.0.
>>> I have a keyframe in the dialogue every other frame because I want the isToggled script to bring the player to the next screen when it's both pressed and lifted.
>>> I have a Movie Clip named Scene 1. On the first frame of that Movie Clip is the action stop(); just a plain stop action, nothing more. I have a screenie of the Movie Clip at the bottom. (I considered the name could be confusing Flash and changed it, but it didn't work that way, either.)
>>> On the outside of the Movie Clip I have these actions:

onClipEvent(enterFrame){
if(Key.isToggled(Key.SPACE)){
this.nextFrame();
}
}

I've tried removing the 'this.' and I've tried it with it, but it won't work either way. It's gotta be this script because I've tried it without the script at all and it's fine.
>>> In case you were wondering, I only have one frame.
>>> And finally, here is a screenie of the timeline within the Movie Clip:

stop(); Not Working?!?


If I offer to help you in a post, PM me to get it. I often forget to revisit threads.
Want 180+ free PSP games? Try these links! - Flash - Homebrew (OFW)

TVK
TVK
  • Member since: Jan. 20, 2005
  • Offline.
Forum Stats
Member
Level 13
Programmer
Response to stop(); Not Working?!? 2009-02-21 20:55:49 Reply

Really, really impressive, this is the first time I've ever seen someone break stop(); in my years of Flash : o
I wouldn't know how to solve it though, have you tried _root.movieclipname.stop(); on the main timeline or gotoAndStop(1); on the second frame in the movieclip, just to see what works and what doesn't?

Kwing
Kwing
  • Member since: Jul. 24, 2007
  • Online!
Forum Stats
Member
Level 45
Game Developer
Response to stop(); Not Working?!? 2009-02-21 21:04:24 Reply

I also wanted to add that sometimes it stops and sometimes it doesn't. It does or doesn't depending on how many times you've pressed the spacebar before exporting it, which makes absolutely no sense. And even when it does stop, pressing space doesn't make the cutscene advance, but makes it play all the way through.

have you tried _root.movieclipname.stop(); on the main timeline

_root. on the main timeline? I tried it with and without the _root. and it didn't work.

or gotoAndStop(1); on the second frame in the movieclip,

gotoAndStop(1); kept it on the first frame, but now it won't advance at all.

I'm about ready to tear my hair out because I'm in a huge collaboration with 4 other people and I'm the only programmer. I can't let them down :(


If I offer to help you in a post, PM me to get it. I often forget to revisit threads.
Want 180+ free PSP games? Try these links! - Flash - Homebrew (OFW)

LostVoices
LostVoices
  • Member since: Mar. 9, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to stop(); Not Working?!? 2009-02-21 21:06:26 Reply

At 2/21/09 09:04 PM, Kwing wrote:

have you tried Key.isDown instead of Key.isToggled


awww

Kwing
Kwing
  • Member since: Jul. 24, 2007
  • Online!
Forum Stats
Member
Level 45
Game Developer
Response to stop(); Not Working?!? 2009-02-21 21:31:59 Reply

It wouldn't work because then it would skip through the frames way too fast, especially because my framerate is 30.

GUYS COME ON!!


If I offer to help you in a post, PM me to get it. I often forget to revisit threads.
Want 180+ free PSP games? Try these links! - Flash - Homebrew (OFW)

Juice-Tin
Juice-Tin
  • Member since: Feb. 3, 2001
  • Offline.
Forum Stats
Member
Level 09
Game Developer
Response to stop(); Not Working?!? 2009-02-21 21:35:33 Reply

toggled is a wonkey thing to use. I don't even know how it works. But think about it, your movieclip always seems to play, even when you have something telling it to go back to the first frame and stop, it always wants to move forward, always want to go to the... next frame :o!

Problem is you have onClipEvent(enterFrame), and flash thinks space is always toggled, therefore it's always doing the nextFrame();

From the looks of it, it seem you want them to go to the next line of dialogue when space is pressed, if so, just use this:

on(keyPress "<Space>"){
	nextFrame();
}

This will only do the next frame each time the space is pressed. If someone holds down space, then it will wait a second, and then do nextFrames repeatedly, it works exactly like holding down a key on the keyboard.


BBS Signature
Kwing
Kwing
  • Member since: Jul. 24, 2007
  • Online!
Forum Stats
Member
Level 45
Game Developer
Response to stop(); Not Working?!? 2009-02-21 21:47:04 Reply

I considered that, but I didn't want anyone to skip my cutscenes. Though I suppose if I don't have a choice, I don't have a choice (wow x=x logic).


If I offer to help you in a post, PM me to get it. I often forget to revisit threads.
Want 180+ free PSP games? Try these links! - Flash - Homebrew (OFW)

LostVoices
LostVoices
  • Member since: Mar. 9, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to stop(); Not Working?!? 2009-02-21 22:07:24 Reply

At 2/21/09 09:31 PM, Kwing wrote: It wouldn't work because then it would skip through the frames way too fast, especially because my framerate is 30.

GUYS COME ON!!

then use a variable! if space is pressed and var is false do this stuff and make the variable true when you release the key the variable is false again

COME ON MAN!!!!!!!


awww

GodlyKira
GodlyKira
  • Member since: Dec. 21, 2008
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to stop(); Not Working?!? 2009-02-21 22:22:38 Reply

1. isToggled is for keys that can be toggled, example caps lock, num lock

2. why are you using AS1...

3. the mc, is probably set to loop 0 times, thats why theres no need for a stop


BBS Signature
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to stop(); Not Working?!? 2009-02-22 07:55:36 Reply

Make a new layer, blank and no key frames, only frames till the end. Then try this script:

onEnterFrame = function (){
if(i==undefined){
i = getTimer();
}
if(getTimer()>i+5000){
i = getTimer();
gotoAndStop(_currentFrame+1);
}
};

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
Juice-Tin
Juice-Tin
  • Member since: Feb. 3, 2001
  • Offline.
Forum Stats
Member
Level 09
Game Developer
Response to stop(); Not Working?!? 2009-02-22 15:26:49 Reply

At 2/21/09 09:47 PM, Kwing wrote: I considered that, but I didn't want anyone to skip my cutscenes. Though I suppose if I don't have a choice, I don't have a choice (wow x=x logic).

Wait.. So you want people to view your cutscenes, but you want the spacebar to advance the frame?
I have no idea what you want to do..


BBS Signature
Juice-Tin
Juice-Tin
  • Member since: Feb. 3, 2001
  • Offline.
Forum Stats
Member
Level 09
Game Developer
Response to stop(); Not Working?!? 2009-02-22 15:31:14 Reply

Oops, I just realized, you mean you want them to press space bar to go to the next piece of dialogue, but not be able to hold it down to skip the scene? If so, this will make it so holding the spacebar does nothing, they will need to let go, and press it again each time:

onClipEvent(enterFrame){
  //Only allow space press once until it's lifted
  if(!spacePressed && Key.isDown(Key.SPACE)){
    spaceDown = true;
    spacePRessed = true;
  }
  //When space is released, allow it to be pressed again next time
  if(!Key.isDown(Key.SPACE)){
    spacePressed = false;
  }
  //When space is first pressed, advancee the frame
  if(spaceDown){
    spaceDown = false;
    nextFrame();
  }
}

BBS Signature
Juice-Tin
Juice-Tin
  • Member since: Feb. 3, 2001
  • Offline.
Forum Stats
Member
Level 09
Game Developer
Response to stop(); Not Working?!? 2009-02-22 15:33:02 Reply

Gah, sorry for triple post, just noticed a typo in the code, spelled one of the variables wrong. Here:

onClipEvent(enterFrame){
  //Only allow space press once until it's lifted
  if(!spacePressed && Key.isDown(Key.SPACE)){
    spaceDown= true;
    spacePressed = true;
  }
  //When space is released, allow it to be pressed again next time
  if(!Key.isDown(Key.SPACE)){
    spacePressed = false;
  }
  //When space is first pressed, advancee the frame
  if(spaceDown){
    spaceDown = false;
    nextFrame();
  }
}

BBS Signature
Blue-Devil23
Blue-Devil23
  • Member since: Sep. 4, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to stop(); Not Working?!? 2009-02-22 16:28:59 Reply

A simpler way is just this:

if(Key.isDown(Key.SPACE) ){
	if(!spacePress){
		spacePress = true;
		nextFrame();
	}
}else{
	spacePress = false;
}
Kwing
Kwing
  • Member since: Jul. 24, 2007
  • Online!
Forum Stats
Member
Level 45
Game Developer
Response to stop(); Not Working?!? 2009-02-22 17:34:41 Reply

Holy crap I already got my answer, guys!

/thread

If I offer to help you in a post, PM me to get it. I often forget to revisit threads.
Want 180+ free PSP games? Try these links! - Flash - Homebrew (OFW)