i made a character that has 5 frames:
1st nothing
2nd axe
3rd spear
4th sword
5th bow
i am trying to make it so the weapons will switch when i press the a,b,c,d,e button on the keyboard( i will figure out the actual button l8r) i have made a mc clip button to make it switch which works but i cant figure out how to do it from the key board
this is my code:
import flash.events.KeyboardEvent;
import flash.events.Event;
var abutton:Boolean;
var bbutton:Boolean;
stage.addEventListener(KeyboardEvent.KEY_DOWN, astage_onKeyDown);
stage.addEventListener(Event.ENTER_FRAME, astage_onEnterFrame);
function astage_onKeyDown(event:KeyboardEvent):void {
if(event.keyCode == 65) {
abutton = true;
}
}
function astage_onEnterFrame(event:Event):void {
if(abutton = true) {
dude.gotoAndStop("bow");
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, bstage_onKeyDown);
stage.addEventListener(Event.ENTER_FRAME, bstage_onEnterFrame);
function bstage_onKeyDown(event:KeyboardEvent):void {
if(event.keyCode == 66) {
abutton = true;
}
}
function bstage_onEnterFrame(event:Event):void {
if(abutton = true) {
dude.gotoAndStop("nothing");
}
}
i have only tried it for the bow and nothing frame
Something like the following where ‘a’, ‘b’ & ‘c’ are your frame labels in ‘character’.
FYI, in your code you have if(abutton = true); should be if(abutton == true) [equality NOT assignment].