Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 BitmapData fillRect with Transparency not working as expected
    text
    copied!<p>I'm trying to use some fillRects on a 32bit BitmapData (i.e. transparency = true and bg color set to FFFF00FF (opaque magenta). For instance I use:</p> <pre><code>fillRect(rect, 0xFF0000FF); </code></pre> <p>This will draw an opaque blue rect, as expected, but ...</p> <pre><code>fillRect(rect, 0x550000FF); </code></pre> <p>This should draw a semi-transparent blue rect, right? But instead I'm getting a dark-blue rect as if the blue is mixed with black (but the background is magenta, remember, so I'd expect the blue gets mixed with the underlying magenta?).</p> <p>If I set the color value to 0x000000FF it should give me the underlying Magenta at 100% but instead I get 100% Black.</p> <p>The BitmapData is created with a 32bit ARGB so I'm wondering what is wrong here?</p> <p>Seems this is default AS3 behavior? After creating a small test class it indeed behaves like I explained ...</p> <pre><code>package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.geom.Rectangle; public class Main extends Sprite { public function Main() { stage.color = 0x000000; var bd:BitmapData = new BitmapData(400, 300, true, 0xFFFF00FF); var b:Bitmap = new Bitmap(bd); addChild(b); bd.fillRect(new Rectangle(0, 0, 200, 200), 0x000000FF); } } } </code></pre> <p>You'd expect the rect drawn with fillRect would be Magenta but it obviously takes the bg color of the stage. Now my question is:</p> <p>Is there a way to get the desired effect (The fillRect alpha applies to the bg color of the bitmapdata, not the Flash stage)?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload