這個switch/case語句總是默認,我不希望發生這種情況。另外,我沒有得到任何錯誤。有人能告訴我我的問題是什麼嗎?該功能總是追蹤我期望的功能,但我希望它能在舞臺上放置一臺推土機。爲什麼這個Switch/Case語句總是默認執行? AS3
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.ui.Mouse;
//START SCREEN
var startScreen: MovieClip;
var bulldozer: MovieClip;
startClick.addEventListener(MouseEvent.CLICK, startGame);
function startGame(event: MouseEvent): void {
startScreen.parent.removeChild(startScreen);
startClick.parent.removeChild(startClick);
var enemyGenerator: Number = Math.random();
switch (enemyGenerator) {
case 0.8 <= enemyGenerator && enemyGenerator <= 1:
stage.addChild(bulldozer);
bulldozer.x = stage.x = 150;
bulldozer.y = stage.y = 150;
break;
case 0.6 <= enemyGenerator && enemyGenerator < 0.8:
stage.addChild(bulldozer);
bulldozer.x = stage.x = 250;
bulldozer.y = stage.y = 250;
break;
case 0.4 <= enemyGenerator && enemyGenerator < 0.6:
stage.addChild(bulldozer);
bulldozer.x = stage.x = 350;
bulldozer.y = stage.y = 350;
break;
case 0.2 <= enemyGenerator && enemyGenerator < 0.4:
stage.addChild(bulldozer);
bulldozer.x = stage.x = 400;
bulldozer.y = stage.y = 400;
break;
case 0 <= enemyGenerator && enemyGenerator < 0.2:
stage.addChild(bulldozer)
bulldozer.x = stage.x = 450;
bulldozer.y = stage.y = 450;
break;
default:
trace (enemyGenerator);
}
startClick.removeEventListener(MouseEvent.CLICK, startGame);
}