lundi 23 novembre 2015

ActionScript3 - Drawing video(webcam) output on BitmapData with shifted position

I'm trying to draw a video(webcam) output on a Bitmapdata, it works if the position of the video is at (0,0) but when I shift the video to (200,0), the drawn output also shifted.

The code is pretty simple

// omitted for brevity

var videoContainer:Sprite = new Sprite();

// Video is added
videoContainer.addChild(video)

// position is offsetted
videoContainer.x = 200;
videoContainer.y = 200;
this.addChild(videoContainer)

// Generate Bitmap
var bd:BitmapData = new BitmapData(video.width, video.height, false, 0x0);
bd.x = video.x;
bd.y = video.y + video.height;
this.addChild(bd);

this.addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(e:Event):void {
    // start drawing
    bd.lock()
    bd.draw(video);
    bd.unlock();
}

enter image description here

I've tried to reposition it with a matrix, but apparently the entire original source had changed.

Is there a way to ensure that the output remains at (0,0) even if the videoContainer were offsetted from (0,0)?

Aucun commentaire:

Enregistrer un commentaire