0

i have a dsgnArea----> a movieclip

dsgnArea is masked by dsgnAreaMask, which inturn is a movieclip

dsgnArea.mask=dsgnAreaMask;

the width,height and position of dsgnAreaMask and dsgnArea are same.

i dynamically added multiple movieclips and labels to dsgnArea; like.. dsgnArea.addChild(movieClip1); dsgnArea.addChild(movieClip2); dsgnArea.addChild(label1); dsgnArea.addChild(label2); and so on...

       these movieclips (movieClip1,movieClip2,......) and labels(label1,label2,....) positions can be altered in runtime..

but as i masked the dsgnArea with dsgnAreaMask, only a portion of the added movieClips and labels are visible...

So, my problem is to grab that visible portion in dsgnArea into a bitmap,like a screenshot of that particular dsgnArea, and save it in my server.

please help me out in this problem.

svKris
  • 783
  • 1
  • 7
  • 21

3 Answers3

1

Say s is the DisplayObject object you want to capture and m is the mask applied on it.

var maskRect:Rectangle = m.getRect(s);
var matrix:Matrix = new Matrix(1, 0, 0, 1, -maskRect.x, -maskRect.y);

var w:Number = Math.min(s.width, maskRect.right) - maskRect.x;
var h:Number = Math.min(s.height, maskRect.bottom) - maskRect.y;

var bd:BitmapData = new BitmapData(w, h);
bd.draw(s, matrix);

Does that work?

Manish
  • 3,472
  • 1
  • 17
  • 16
  • hey mj. this is not working with masked movie clips,but its fine with unmasked movieclips.. – svKris Feb 09 '11 at 05:48
0

The BitmapData draw method is what you are looking for. You can use it's clipRect param to define what you would like to draw (the masked parts).

maxmc
  • 4,218
  • 1
  • 25
  • 21
0

Quasimondo did a handy little method to do this (take a snapshot of the whole displayObject), it's available here: http://www.quasimondo.com/archives/000670.php

I don't know if it works with masked content though. if it doesn't, the trick would be to translate the whole content by the size of the mask

var bounds:Rectangle = dsgnAreaMask.getBounds( dsgnAreaMask );

instead of using the content of the clip

var bounds:Rectangle = clip.getBounds( clip );

as far as saving file to server is concerned, the question was asked (answered?) here AS3 Save Media File to server

Community
  • 1
  • 1
nicoptere
  • 1,067
  • 6
  • 9