2
* This file is part of the dis-Emi-A HaXe Library. Copyright (c) edA-qa mort-ora-y
3
* For full copyright and license information please refer to doc/license.txt.
8
import flash.display.Bitmap;
9
import flash.display.BitmapData;
10
import flash.display.Sprite;
12
import flash.events.MouseEvent;
13
import flash.events.Event;
16
* This demonstrates an alisgnment problem in Flash when drawing to bitmaps
17
* using the ERASE mode. The three boxes on the screen should be aligned
18
* on both sides, but they are not, the bottom one is one-pixel smaller to the left
19
* and 2 pixesl smaller to the right
21
* Hmm, isolated like this I can't see a problem. :(
23
class FlashDefectErase extends ui.StageLayout
34
function _resize( w : Float, h : Float )
36
//remove children if not first time
46
graphics.beginFill( 0xFF0000 );
47
graphics.drawRect( 0, 0, w, h );
50
var left = Math.floor( w/ 4 );
51
var right = Math.floor( w - left );
52
var mid = Math.floor( h/3 );
54
//setup graphic to draw (will server as first child as well)
56
boxS.graphics.beginFill(0x00FF00);
57
boxS.graphics.lineStyle( 2, 0x0000FF );
58
boxS.graphics.drawRect( left, 0, right - left, mid );
59
boxS.graphics.endFill();
62
var bit = new BitmapData( Math.ceil(w), mid, true, 0x00000000 );
64
bitS = new Bitmap( bit );
68
//create erased bitmap
69
var sub = new BitmapData( Math.ceil( w ), mid, true, 0xFF00FF00 );
70
sub.draw( boxS, null, null, flash.display.BlendMode.ERASE );
71
subS = new Bitmap( sub );
81
static public function main()
83
ui.StageLayout.setup( FlashDefectErase );