In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

ByteArrayを使用したビットマップ塗りつぶしのテスト

ByteArrayを使用したビットマップ塗りつぶしのテスト
/**
 * Copyright TheCoolMuseum ( http://wonderfl.net/user/TheCoolMuseum )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/d2Ga
 */

// forked from TheCoolMuseum's flash on 2009-7-12
// ByteArrayを使用したビットマップ塗りつぶしのテスト
package {
    import flash.display.*;
    import flash.geom.*;
    import flash.utils.*;
    
    public class FlashTest extends Sprite {
        private var iWidth:int = 480;
        private var iHeight:int = 480;
        
        public function FlashTest() {
              var bmd:BitmapData = new BitmapData(iWidth, iHeight, true);
              var img:ByteArray = new ByteArray();
              
              for(var i:int=0; i<1; i++){ //1回描画 テスト用
                  for(var y:int=0; y<iHeight; y++){
                      var r:uint = uint(y/iHeight*256);
                      var pos:int = y*iWidth*4;
                      for(var x:int=0; x<iWidth; x++){
                          img[pos] = 0xff;
                          img[pos+1] = r;
                          img[pos+2] = uint(x/iWidth*256);
                          img[pos+3] = 0x00;
                          pos+=4;
                      }
                  }
              }
              bmd.setPixels(bmd.rect, img);
 
              addChild(new Bitmap(bmd));
        }
    }
}