Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A long time ago I was looking for the same thing and I tried using loops to check for each pixel. But that took <strong>a lot</strong> of time and consumed incredible amount of CPU. Luckily we have the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#compare%28%29" rel="nofollow"><code>BitmapData.compare()</code></a> method, which outputs a Bitmapdata if there are any diferences in compared BitmapData objects.</p> <p>Also there's the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#transparent" rel="nofollow"><code>BitmapData.transparent</code></a> property, which actually directly gives you the answer as a Boolean. But I have never used it directly on a loaded image myself.</p> <pre><code>import flash.display.Loader; import flash.net.URLRequest; import flash.events.Event; import flash.display.Bitmap; import flash.display.BitmapData; import flash.geom.Point; var ldr:Loader = new Loader(); var req:URLRequest = new URLRequest('someImage.png'); ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,imgLoaded); ldr.load(req); function imgLoaded(e:Event):void { var l:Loader = e.target.loader, bmp:Bitmap = l.content as Bitmap, file:String = l.contentLoaderInfo.url.match(/[^\/\\]+$/)[0]; trace(bmp.bitmapData.transparent); // I think this default property should do it but // in case it does not, here's another approach: var trans:Boolean = isTransparent(bmp.bitmapData); trace(file,'is'+(trans ? '' : ' not'),'transparent'); } function isTransparent(bmpD:BitmapData):Boolean { var dummy:BitmapData = new BitmapData(bmpD.width,bmpD.height,false,0xFF6600); // create a BitmapData with the size of the source BitmapData // painted in a color (I picked orange) dummy.copyPixels(bmpD,dummy.rect,new Point()); // copy pixels of the original image onto this orange BitmapData var diffBmpD:BitmapData = bmpD.compare(dummy) as BitmapData; // this will return null if both BitmapData objects are identical // or a BitmapData otherwise return diffBmpD != null; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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