Okay, so i wrote this walking code, but it isn’t working. I would post the fla, but i dont have anywhere to put it, so i will explain what i have the best i can. The problem is that i cant get the walk animation to play when i press the button, i can only get the first frame of each direction
i have a main character movie clip with the instance name ninja. Inside there are four frames labeled t, b, r, l, and in each of these frames there is a stop action. The four mcs of the different walking directions are instance name ninjat, ninjab, ninjar, and ninjal. There are nine frames in each one. The first frame says stop, and the last frame say goto and play 2 (this is in each direction mc). Here is my code for the main ninja mc.
ActionScript:
onClipEvent (load) {
_root.downwalk = true;
_root.upwalk = true;
_root.rightwalk = true;
_root.leftwalk = true;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT) && _root.rightwalk == true) {
this.gotoAndStop(“r”);
_root.ninjar.play();
_root.ninjal.play();
_root.ninjab.play();
_root.ninjaf.play();
_root.leftwalk == true;
}
if (Key.isDown(Key.LEFT) && _root.leftwalk == true) {
this.gotoAndStop(“l”);
_root.rightwalk == true;
_root.ninjar.play();
_root.ninjal.play();
_root.ninjab.play();
_root.ninjaf.play();
}
if (Key.isDown(Key.UP) && _root.upwalk == true) {
this.gotoAndStop(“b”);
_root.upwalk == true;
_root.ninjar.play();
_root.ninjal.play();
_root.ninjab.play();
_root.ninjaf.play();
}
if (Key.isDown(Key.DOWN) && _root.downwalk == true) {
this.gotoAndStop(“f”);
_root.downwalk == true;
_root.ninjar.play();
_root.ninjal.play();
_root.ninjab.play();
_root.ninjaf.play();
}
}
onClipEvent (keyUp) {
_root.ninjab.gotoAndStop(1);
_root.ninjaf.gotoAndStop(1);
_root.ninjal.gotoAndStop(1);
_root.ninjar.gotoAndStop(1);
}
Can some body help me fix this
just replace all the _root’s to this in front of the ninjar, ninjal, ninjab, ninjaf. These mc’s are not located in the root but inside _root.ninja, or because you give these actions to that ninja: this; so:
onClipEvent (load) {
_root.downwalk = true;
_root.upwalk = true;
_root.rightwalk = true;
_root.leftwalk = true;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT) && _root.rightwalk == true) {
this.gotoAndStop("r");
this.ninjar.play();
this.ninjal.play();
this.ninjab.play();
this.ninjaf.play();
_root.leftwalk = true;
}
if (Key.isDown(Key.LEFT) && _root.leftwalk == true) {
this.gotoAndStop("l");
_root.rightwalk = true;
this.ninjar.play();
this.ninjal.play();
this.ninjab.play();
this.ninjaf.play();
}
if (Key.isDown(Key.UP) && _root.upwalk == true) {
this.gotoAndStop("b");
_root.upwalk = true;
this.ninjar.play();
this.ninjal.play();
this.ninjab.play();
this.ninjaf.play();
}
if (Key.isDown(Key.DOWN) && _root.downwalk == true) {
this.gotoAndStop("f");
_root.downwalk = true;
this.ninjar.play();
this.ninjal.play();
this.ninjab.play();
this.ninjaf.play();
}
}
onClipEvent (keyUp) {
this.ninjab.gotoAndStop(1);
this.ninjaf.gotoAndStop(1);
this.ninjal.gotoAndStop(1);
this.ninjar.gotoAndStop(1);
}
N.B. You could also make this script a lot smaller (for instance by using for-loops and arrays). Haven’t got the time right now to help you, try it, and if you need help just yell.
oh and even a better way to shorten it, is to use the same instance name (instead of ninjab, ninjaf… use ninja_anim) for all of them, you can do this because it’s inside a different frame. You can change
this.ninjar.play();
this.ninjal.play();
this.ninjab.play();
this.ninjaf.play();
to this
this.ninja_anim.play();
here’s your shortened version, found some time after all :geek:
u rok all of u esp seticus. Ok maybe just seticus, but i know the rest of you would have helped if he didnt beat you to it
pleasure helping you, sorry if I had beaten somebody (elbudster) to it…
hehe, i couldn’t do anything anyways since i don’t have 2004