📄 switchoperation.as
字号:
package org.kingda.book.procedureprogram
{
import flash.display.Sprite;
public class SwitchOperation extends Sprite
{
public function SwitchOperation() {
//sampleSwitchStandard();
sampleSwitchOmitBreak();
}
private function sampleSwitchStandard():void {
var fruits:Array = ["苹果","香蕉","葡萄","金橘","小番茄"];
//从水果数组中随机取一个赋值给currentFruit变量
var currentFruit:String = fruits[Math.floor(Math.random()*fruits.length)];
switch(currentFruit) {
case "苹果":
trace ("按苹果价付钱");
break;
case "香蕉":
trace ("按香蕉价付钱");
break;
default:
trace ("^0^ 免费品尝:" + currentFruit);
}
}
private function sampleSwitchOmitBreak():void {
var fruits:Array = ["苹果","香蕉","葡萄","金橘","小番茄"];
//从水果数组中随机取一个赋值给currentFruit变量
var currentFruit:String = fruits[Math.floor(Math.random()*fruits.length)];
trace (currentFruit);
switch(currentFruit) {
case "葡萄":
trace ("哎,葡萄!");
case "小番茄":
trace ("免费品尝!");
break;
case "苹果":
case "香蕉":
trace ("按香蕉价付钱");
break;
default:
trace ("一定是金橘。");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -