Hi,
I wanted to put on the stage a png file with some transparent areas, unfortunately it weight too much.
So instead I thought I’ll create a shape object and use jpeg image as it’s mask…
This is my code:
package {
import flash.display.Bitmap;
import flash.display.Shape;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
public class Map extends MovieClip {
private var color :Shape = new Shape;
private var map :Bitmap = new Bitmap;
private var loader :Loader = new Loader();
public function Map():void {
color.graphics.beginFill(0xFF0000, 1);
color.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
color.graphics.endFill();
loader.load(new URLRequest("map.jpg"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, draw);
}
private function draw(e:Event):void {
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, draw);
map = loader.content as Bitmap;
addChild(color);
color.mask = map;
}
}
}
And it doesn’t work, can I use jpeg images to mask the shape at all?
Thx
Z