AS2での定数の指定

| コメント(0) | トラックバック(0)

as3では書き換えられない値「定数」として const があるが、

as2にはないので、読み取り専用にして書く。
 
また、定数を一つのファイルにまとめる場合は、下記のようにする。
 
Constants.as
------------------------------------------------------------------------------------------
/**
 * 定数を保持するクラス
 * @author kazy
 * @version 1.0
 * @since 1.0
 */
class Constants
{
private static var SERVER_PATH = "../"
/**
* CONTENT_PATH
* @return CONTENT_PATH 本体ファイルcontent.swfへのパスを返します
*/
static public function get CONTENT_PATH() { return SERVER_PATH + "swf/content.swf"; }
}
------------------------------------------------------------------------------------------
 
使用するときは
 
import Constants;
mcl.loadClip(Constants.CONTENT_PATH, content);
 

トラックバック(0)

トラックバックURL: http://www.kazy.jp/mt4/mt-tb.cgi/18

コメントする