Transparency in a loaded JPEG image


hi there,
im quite new actionscript scene apologies if question has been answered elsewhere. creating 2d shooting game, , im loading multiple images of various enemies several jpg files, when display these on screen images have big black square round them. when programming in language such opengl, if wanted rid of enable alpha blending function , set 100% transparency black colour want hide. load jpeg file , store in bitmapdata variable, , copy new bitmapdata variable transparency enabled , set 0x00000000 (fully transparent black). thought solve problem butt no joy. code shown below:

public class graphicsloader extends sprite {

public var loader:loader; // bitmap loader
public var bmp1:bitmap;

public function graphicsloader(path:string)
{
// create loader
loader = new loader( );
// register notified when bitmap has been loaded
// , initialized
loader.contentloaderinfo.addeventlistener(event.init, initlistener, false, 0, true);
// load bitmap
loader.load(new urlrequest(path));
}

// triggered when bitmap has been loaded , initialized
private function initlistener (evt:event):void
{
var img:bitmapdata = bitmap(loader.content).bitmapdata;

var canvas:bitmapdata = new bitmapdata(img.width, img.height, true, 0x00000000);
canvas.draw(img);

bmp1= new bitmap(canvas);
bmp1.x = 450;
bmp1.y = 100;
addchild(bmp1);
var bmp2:bitmap = new bitmap(canvas);
bmp2.rotation = 45;
bmp2.x = 50;
bmp2.y = 100;
bmp2.scalex = 2; // 200%
bmp2.scaley = 2; // 200%
addchild(bmp2);
}
}

i think problem may jpegs dont store alpha channel presume have create alpha layer in actionscript, how combine image remove black background?

its doing head in because know should simple task cant work. or advice appreciated.

thanks

robert

and using png instead of jpg not option?


More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62