 |
- if/else if statements
- if (daytime){
gotoWork();
}else if (raining){
stayHome();
}else if (snowing){
goSkiing();}
- Example
- stage.addEventListener(KeyboardEvent.KEY_DOWN, detectText);
function detectText(myevent:KeyboardEvent):void{
if (myevent.keyCode==Keyboard.UP){
beetle_mc.rotation = 0;
beetle_mc.y -= 30;
}
}
- What happens when you test the movie and you press the up key?
- How would you get to go in other directions?
- How would you rotate it to go in other directions?
- You could use the switch, case and default statements:
- switch (weather){
case sun:
bringSunglasses();
break;
case rain:
bringUmbrella();
break;
case snow:
bringSkis();
break;
default:
stayHome();
break;
}
- I'll get you started:
- stage.addEventListener(KeyboardEvent.KEY_DOWN, detectText);
function detectText(myevent:KeyboardEvent):void{
switch (myevent.keyCode){
case Keyboard.UP:
- see if you can complete the same set of circumstances
|