BLOG ARTICLE KB/Action Script | 1 ARTICLE FOUND

  1. 2011.08.24 [action script] 이중 배열 사용하기



이중 배열은 new Array ( [0,1,2], [3,4,5] )이런식으로 생성하면 된다.

코드는 아래와 같이 작성하였다.

package { import flash.display.Sprite; import flash.events.Event; import flash.display.*; public class FlashTest extends Sprite { private var img:Array = new Array ( [0,0,0,1,1,1,0,0,0,0], [0,0,0,1,1,1,0,0,0,0], [0,0,0,1,1,0,0,0,0,0], [0,1,1,1,1,1,1,1,0,0], [0,1,1,1,1,1,1,1,0,0], [0,0,0,1,1,0,0,0,0,0], [0,0,0,1,1,1,0,0,0,0], [0,0,1,1,1,1,0,0,0,0], [0,1,1,0,1,1,0,0,0,0], [1,1,0,1,1,1,0,0,0,0] ); private var _bitmap:BitmapData= new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xff000000); private var _image:Bitmap= new Bitmap(_bitmap); public function FlashTest() { // write as3 code here.. addChild( _image ); addEventListener( Event.ENTER_FRAME, onEnterFrame ); } public function onEnterFrame (event:Event) : void { for ( var x:int = 0 ; x < 10; x ++ ) { for ( var y:int = 0 ; y < 10; y ++ ) { var col:int; if ( img[y][x] == 1 ) col = 0x000000ff; else col = 0x00000000; _bitmap.setPixel( 100 +x, 100 +y, col ); } } } } }

코딩은 wonderfl.net에서 진행하였다.



실행 결과:

flash on 2011-8-24 - wonderfl build flash online



'KB > Action Script' 카테고리의 다른 글

[action script] 이중 배열 사용하기  (0) 2011.08.24
YOUR COMMENT IS THE CRITICAL SUCCESS FACTOR FOR THE QUALITY OF BLOG POST


티스토리 툴바