Hey there,
I'm trying to mask an FLV with a PNG alpha channel. I'm using BitmapData (from a PNG) but it's not working. Is there anything I'm missing? Cut up code below:
var musclesLoader:Loader = new Loader();
var musclesContainer:Sprite = new Sprite();
var musclesImage:Bitmap = new Bitmap();
var musclesBitmapData:BitmapData;
var musclesVideo:Video = new Video(752, 451.2);
var connection:NetConnection = new NetConnection();
var stream:NetStream;
function loadMuscles():void {
musclesLoader.load(new URLRequest('img/muscles.png'));
musclesLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, musclesComplete);
}
function musclesComplete():void {
musclesBitmapData = new BitmapData(musclesLoader.content.width, musclesLoader.content.height, true, 0x000000);
musclesImage.bitmapData = musclesBitmapData;
musclesImage.smoothing = true;
musclesContainer.addChild(musclesImage);
contentContainer.addChild(musclesContainer);
}
function loadMusclesVideo():void {
connection.connect(null);
stream = new NetStream(connection);
stream.client = this;
musclesVideo.mask = musclesBitmapData;
stage.addChild(musclesVideo);
musclesVideo.attachNetStream(stream);
stream.bufferTime = 1;
stream.receiveAudio(true);
stream.receiveVideo(true);
stream.play("vid/muscles.flv");
}
Outside this code I have a function that adds the containers to the stage, etc and places the objects in the appropriate spots. It sort of works - the mask applies, but in a square (the size of the boundaries of musclesBitmapData) rather than with the shape of the alpha channel.
Is this the right way to go about this?