1 Attachment(s)
[AS2] Won't remove and replace MovieClip when key is pressed
Hi everyone. This is my first appearance here. I'm interested in using AS2 to learn object-oriënted programming, and one of the methods I think I will use the most is to develop games. Now, I'm trying to make a up-down-left-right character control, but the character will always appear on the centre, only changing oriëntation. (You can see this method of character control in games like Pokémon).
Attachment 75305
Code:
this.attachMovie('charup', 'karakter', 1);
karakter._x = 250;
karakter._y = 170;
if (Key.isDown(Key.LEFT)) {
this.removeMovieClip('karakter');
this.attachMovie('charle', 'karakter', 1);
backgro._x = backgro._x + 50;
}
I tried to compile this script but what I get is that the lines 1-3 worked seamlessly, but the subsequent lines didn't work. I wonder what is wrong. I have a couple of books relating to Flash 8 game development (which I utilised in my childhood to create Flash games too, but just by copying the code on the CDs given though) and I think I will have much time to spend doing this on the upcoming college holiday. Now I would like to master the programming (I have outlined a simple algorithm of the AI, how would they respond if they get attacked, how will objects that move constantly have no problems moving when the background moves as a result of the player moving). I can make the simple algorithms but I'm still blind to the syntaxes.
I'm looking for responses and I'll appreciate any assistance given.
Thank you.