设置为 const 名称后跟一个数字。并使用带有Math.random()
.
试试这个
package {
import flash.display.Sprite;
public class MyClass extends Sprite
{
public static const constA:String = "00";
public static const constB:String = "11";
public static const constC:String = "22";
public static const constD:String = "33";
public static const constE:String = "44";
public static const constF:String = "55";
public static const constG:String = "66";
public static const constH:String = "77";
public static const constI:String = "88";
public static const constJ:String = "99";
.
.
.
public function MyClass()
{
MyClass.test();
}
public static function mapped(i:int):String
{
//65 is A
return String.fromCharCode(65+i);
}
public static function test():void
{
trace(MyClass["const"+mapped(int(Math.random()*10))]);
}
}
}