リプタクのもう覚えられません
Google
Web サイト内
topmemo ▶ 配列の中に配列を作る

ActionScript

配列の中に配列を作る

配列の中に配列(2次元配列)を作るサンプル。

//配列の中に配列(2次元配列)を作るサンプル
var myArray:Array =[
					["a","b","c"],
					["あ","い","う"],
					["1","2","3","4"],
					]
trace(myArray);//a,b,c,あ,い,う,1,2,3,4



//配列の一部を抜き出し確認
trace(myArray[0][2]);//c
trace(myArray[2][3]);//4



//配列を追加する
myArray.push(["A","B","C"]);
trace(myArray);//a,b,c,あ,い,う,1,2,3,4,A,B,C



//配列を追加する2
var myArray_2:Array = ["一","二","三"];//新規配列を作成
myArray.push(myArray_2);
trace(myArray);//a,b,c,あ,い,う,1,2,3,4,A,B,C,一,二,三



//配列の一部を抜き出して確認
trace(myArray[3][0]);//A
trace(myArray[4][1]);//二



/*
最終的な配列の構成は下記と同じ
var myArray:Array =[
					["a","b","c"],
					["あ","い","う"],
					["1","2","3","4"],
					["A","B","C"],
					["一","二","三"],
					]
*/
last update 2009.7.3
参考・出典等
「特に無し」

▲page top

topmemogallery||blogtestaboutmail
Copylight(C)2008-2009 Riptac. All Rights Reserved.