Strike Force Heroes 2
The explosive sequel to the hit game Strike Force Heroes!
3.96 / 5.00 8,967 ViewsObsolescence
Defeat the enormous mechanical beasts--and become one of them.
4.02 / 5.00 43,334 ViewsDoes anyone know how the 'Spacebar mechanism' of Super Mario Bros Z works. I can't get it to work.
I got this code, but I can't use it right because the video keeps on playing, while in smbz it keeps on the dialogue until you press 'Spacebar'.
The code:
var myKeyListener:Object = new Object();
Key.addListener(myKeyListener);
myKeyListener.onKeyUp = function ()
{
if (Key.getCode() == Key.SPACE)
{
gotoAndPlay(453);
Key.removeListener(myKeyListener);
}
}
what you're doing is setting it to a frame then removing the listener, im not sure what you're trying to do?
At 6/27/12 09:30 PM, caseymacneil wrote: what you're doing is setting it to a frame then removing the listener, im not sure what you're trying to do?
He wants it so when he presses Space he goes to X frame.
At 6/27/12 12:32 PM, dbzmf2 wrote: Does anyone know how the 'Spacebar mechanism' of Super Mario Bros Z works. I can't get it to work.
I got this code, but I can't use it right because the video keeps on playing, while in smbz it keeps on the dialogue until you press 'Spacebar'.
The code:
var myKeyListener:Object = new Object();
Key.addListener(myKeyListener);
myKeyListener.onKeyUp = function ()
{
if (Key.getCode() == Key.SPACE)
{
gotoAndPlay(453);
Key.removeListener(myKeyListener);
}
}
Whoa. Okay.
First: I'm not sure that a Listener is an Object (though I may be wrong)
Second:
stage.addEventListener(KeyboardEvent.KEY_UP, myKeyListener);
private function myKeyListener(e:KeyboardEvent):void{
if(e.keyCode == 32){
yourMC.gotoAndPlay(453);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, myKeyListener);
}
}
Third: That's AS3, and I believe you're using AS2
_root.onEnterFrame = function(){
if(Key.isDown(32)){
yourMC.gotoAndPlay(453);
}
}
or
onClipEvent(enterFrame){
if(Key.isDown(32)){
gotoAndPlay(453);
}
}
Fourth: Why in the world does your movieclip have 453 frames? That should not have that many frames. Split it into smaller MCs, you'll be glad you did when you have to go back and edit them.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
That code's correct, I wrote it myself, the just can't implement it properly, test it yourself:
//On a frame
var myKeyListener:Object = new Object();
Key.addListener(myKeyListener);
myKeyListener.onKeyUp = function()
{
if (Key.getCode() == Key.SPACE)
{
trace("test");
Key.removeListener(myKeyListener);
}
};
I see most people don't use AS2 listeners and prefer the AS1 approach. . .
At 6/27/12 10:21 PM, MintPaw wrote: That code's correct, I wrote it myself, the just can't implement it properly, test it yourself:
I haven't tested it yet, but that's odd... Wouldn't getCode() return a number? You're comparing a number to Key.SPACE
I see most people don't use AS2 listeners and prefer the AS1 approach. . .
Yeah, I never really used listeners in AS2. Why? Because I had no idea how. Just old habits resurfacing.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
double-post, but after a bit of tinkering i've figured some things out.
1) class Key contains a public static "space", which is an int(uint?) of 32
2) Mint's right, the code does in fact, work.
3) Listeners are Objects - interesting.
4) onKeyUp can, in fact, be a function
5) You can add listeners to a pre-built class that's intended for input
and here I thought I was supposed to be learning AS3 .-.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
1) class Key contains a public static "space", which is an int(uint?) of 32
Number. Datatypes int and uint don't exist in AS2.
How did you think Key.isDown(Key.LEFT) worked?
2) Mint's right, the code does in fact, work.
Yes it does.
3) Listeners are Objects - interesting.
As are everything.
4) onKeyUp can, in fact, be a function
What else could if of been.
5) You can add listeners to a pre-built class that's intended for input
Key is an EventDispatcher in AS2. Key.isDown() is a deprecated functions that's no longer fully supported by AS2 but still may be used.
At 6/27/12 11:53 PM, MintPaw wrote:1) class Key contains a public static "space", which is an int(uint?) of 32Number. Datatypes int and uint don't exist in AS2.
How did you think Key.isDown(Key.LEFT) worked?
2) Mint's right, the code does in fact, work.Yes it does.
3) Listeners are Objects - interesting.As are everything.
4) onKeyUp can, in fact, be a functionWhat else could if of been.
5) You can add listeners to a pre-built class that's intended for inputKey is an EventDispatcher in AS2. Key.isDown() is a deprecated functions that's no longer fully supported by AS2 but still may be used.
Thank you all for you help. It worked but with a different code (sorry, I found it out like 2 minutes before I went to sleep).
This is the code I used:
stop ();
onEnterFrame = function ()
{
if (!Key.isDown(32))
{
_root.allow = true;
}
else if (Key.isDown(32) && _root.allow == true)
{
play ();
_root.allow = false;
}
};
Make sure to "delete onEnterFrame" when you don't want Space to advance anymore.
At 6/27/12 11:14 PM, egg82 wrote: 3) Listeners are Objects - interesting.
You need something that has the handler function.
You can omit the "listener" object, by doing Key.addListener(this); and placing the function on the main timeline.
5) You can add listeners to a pre-built class that's intended for input
That's why most of the time a generic Object is created, which is dynamic.
and here I thought I was supposed to be learning AS3 .-.
If you look at AsBroadcaster you will see that As3 is actually not that far away.
It's just not buried as deep into As2 as EventDispatcher is in As3. Which made it a bit uncommon.
Sorry to bring this up again like so many others.
But I'm looking for a similar function. However I want audio to keep playing and make it possible for animation loops.