I am brand new to AS so I do not know very much yet.
I have a mc called boy and I have an instance of that mc called boy_mc. I have figured out how to make his position change on the stage, but I cannot figure out how to do some other things. Here is the code that I have so far:
import flash.events.KeyboardEvent;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(evt:KeyboardEvent):void
{
switch(evt.keyCode)
{
case Keyboard.RIGHT :
boy_mc.x += 5;
break;
case Keyboard.LEFT :
boy_mc.x -= 5;
break;
default :
break;
}
switch(evt.keyCode)
{
case Keyboard.UP :
boy_mc.y -= 5;
break;
case Keyboard.DOWN :
boy_mc.y += 5;
break;
default :
break;
}
}
I am trying to learn 3 things.
-
How do I make him be facing left when I push left and facing right when I push to right?
-
How to I restrict him to a certain area of the stage? I am going to have some buildings on the top and I don’t want him to be able to walk past the street level. So basically I don’t want him to be able to go off the stage or up some to be determined height.
-
When he walks up and touches a door on my stage, I want to jump to another place in the timeline. I do not know how to do that though, but I assume it has something to do with collision detection?
Thanks in advance!