const 名とそれに続く数値に設定します。を使用して Dictionary アプローチ メソッドを使用し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))]);
}
}
}