# \[help\] get the alpha channel value from external .png

**URL:** <https://forum.kirupa.com/t/help-get-the-alpha-channel-value-from-external-png/228451>\
**Category:** flash\
**Created:** [June 7, 2007, 9:43pm UTC](https://forum.kirupa.com/t/help-get-the-alpha-channel-value-from-external-png/228451 "2007-06-07T21:43:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yashiharu](https://avatars.discourse-cdn.com/v4/letter/y/bb73d2/32.png) [@yashiharu](https://forum.kirupa.com/u/yashiharu)\
**Post date:** [June 7, 2007, 9:43pm UTC](https://forum.kirupa.com/t/help-get-the-alpha-channel-value-from-external-png/228451/1 "2007-06-07T21:43:03Z")

</div>

[LEFT]i can now getPixel() from a external jpg  
but what i finallly want to achieve, is getPixel32()  
the alpha value is always FF(255)  
i don’t know why …  
can anyone see the problem?

[[COLOR=#22229c]http://www.senocular.com/flash/source.php?id=0.168[/COLOR]](http://www.senocular.com/flash/source.php?id=0.168)  
take a look on this sample~  
in this sample the photo is partially transparent, i can see that in photoshop  
if i put my code in this file, the color picker can tell the alpha changes.  
that why i still think there is a chance for getting the alpha value from external .png~  
just don’y know how to achieve it T\_T  
(i’ve try transparent png and also alpha channel added png, doesn’t work like the sample)

```auto
 [LEFT]import flash.display.BitmapData; 
import flash.geom.ColorTransform; 
import flash.geom.Matrix; 

Stage.scaleMode = 'noScale'; 
Mouse.hide(); 

pixData_xml = new XML(); 
pixData_xml.onLoad = startGetPix; 
pixData_xml.load("pixData.xml"); 
pixData_xml.ignoreWhite = true; 

picListener = new Object(); 
picLoader = new MovieClipLoader(); 
picListener.onLoadInit = function(target_mc:MovieClip) { 
   getPix(); 
}; 
picLoader.addListener(picListener); 

function startGetPix(success) { 
   imgPath = pixData_xml.childNodes[0].firstChild.attributes.imgURL; 
   picLoader.loadClip(imgPath,img_mc); 
} 
var image_bitmap; 
function getPix() { 
   image_bitmap = new flash.display.BitmapData(img_mc._width, img_mc._height); 
   image_bitmap.draw(img_mc,new Matrix()); 
   var channelBitmap = image_bitmap.clone(); 
   channel_mc.attachBitmap(channelBitmap, 1); 

var sourceRect = image_bitmap.rectangle;
var offset = new flash.geom.Point(0,0);
   channelBitmap.copyChannel(image_bitmap, sourceRect, offset, 8, 8); 

} 

onMouseMove = function () { 
   picker_mc._x = _xmouse; 
   picker_mc._y = _ymouse; 
   var curr_color:Number = image_bitmap.getPixel32(img_mc._xmouse, img_mc._ymouse); 
   var preview_colortansform = new flash.geom.ColorTransform(); 
   preview_colortansform.rgb = curr_color; 
   color_mc.transform.colorTransform = preview_colortansform; 
    
   var alpha:String = (curr_color >> 24 & 0xFF).toString(16); 
   trace(">> alpha: "+alpha); 
   // ff 
   var red:String = (curr_color >> 16 & 0xFF).toString(16); 
   trace(">> red: "+red); 
   // aa 
   var green:String = (curr_color >> 8 & 0xFF).toString(16); 
   trace(">> green: "+green); 
   // cc 
   var blue:String = (curr_color & 0xFF).toString(16); 
   trace(">> blue: "+blue); 
   // ee 
   trace("0x"+alpha+red+green+blue); 
   // 0xffaaccee 
   hex_txt.text = "0x"+alpha+red+green+blue; 
   updateAfterEvent(); 
};[/LEFT]

```

[/LEFT]
