Flash Practice BitmapCompare

by com4dc
♥0 | Line 27 | Modified 2012-01-20 23:47:06 | MIT License
play

ActionScript3 source code

/**
 * Copyright com4dc ( http://wonderfl.net/user/com4dc )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rTRO
 */

package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.geom.Rectangle;
    
    public class BitmapCompare extends Sprite {
        public function BitmapCompare() {
            // write as3 code here..
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            
            //draw many random line
            graphics.lineStyle(0); 
            for(var i:int = 0; i < 100; i++) {
                graphics.lineTo(Math.random() * 300,Math.random() * 400);
            }
            
            var bmpd1:BitmapData = new BitmapData(300,200,false,0xffffff);
            bmpd1.fillRect(new Rectangle(100,50,100,100), 0xff0000);
            var bmp1:Bitmap = new Bitmap(bmpd1);
            addChild(bmp1);
            
            // 
            var bmpd2:BitmapData = new BitmapData(300,200,true,0x00ffffff);
            bmpd2.fillRect(new Rectangle(100,50,100,100), 0x80ff0000);
            var bmp2:Bitmap = new Bitmap(bmpd2);
            bmp2.y=200;
            addChild(bmp2);
        }
    }
}