I had the same problem a while ago, here was my final solution
[as]
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.geom.Matrix;
//
function staticCloneMC(target, mc, padding) {
var bounds = mc.getBounds(mc);
var offset_y = padding;
var offset_x = padding;
bounds.height = bounds.yMax-bounds.yMin;
bounds.width = bounds.xMax-bounds.xMin;
var w = bounds.width+offset_x;
var h = bounds.height+offset_y;
bounds.x = bounds.xMin-offset_x/2;
bounds.y = bounds.yMin-offset_y/2;
var lvl = target.getNextHighestDepth();
var clip = target.createEmptyMovieClip("dupe_"+mc._name+"_"+lvl, lvl);
var holder = clip.createEmptyMovieClip("holder", 1);
clone_bitmap = new BitmapData(w, h, true, 0x00000000);
holder.attachBitmap(clone_bitmap, 1, "auto", true);
clone_bitmap.draw(mc, new Matrix(1, 0, 0, 1, bounds.x*-1, bounds.y*-1));
holder._x = bounds.x;
holder._y = bounds.y;
clip._x = mc._x;
clip._y = mc._y;
clip.bitmap=clone_bitmap
return clip;
}
function animCloneMC(target, mc, padding) {
var lvl = target.getNextHighestDepth();
var clip = target.createEmptyMovieClip("dupe_"+mc._name+"_"+lvl, lvl);
var holder = clip.createEmptyMovieClip("holder", 1);
clip.mc = mc;
clip.padding = padding;
clip.onEnterFrame = function() {
var bounds = this.mc.getBounds(this.mc);
var offset_y = this.padding;
var offset_x = this.padding;
bounds.height = bounds.yMax-bounds.yMin;
bounds.width = bounds.xMax-bounds.xMin;
var w = bounds.width+offset_x;
var h = bounds.height+offset_y;
bounds.x = bounds.xMin-offset_x/2;
bounds.y = bounds.yMin-offset_y/2;
clone_bitmap = new BitmapData(w, h, true, 0x00000000);
holder.attachBitmap(clone_bitmap, 1, "auto", true);
clone_bitmap.draw(mc, new Matrix(1, 0, 0, 1, bounds.x*-1,
bounds.y*-1));
holder._x = bounds.x;
holder._y = bounds.y;
};
clip._x = mc._x;
clip._y = mc._y;
clip.bitmap=clone_bitmap
return clip;
}
[/as]
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Niclas Åberg
Sent: 10 January 2007 13:50
To: [email protected]
Subject: [Flashcoders] Copy negative pixels from a movie clip
using draw()
Hi all,
I'm using the BitmapData.draw method, and I've bumped into a
problem. I need to copy all the pixels from a movie clip,
including the pixels which are on negative coordinates. I've
only succeeded copying the ones on positive coordinates. Has
anyone experienced the same thing, and, maybe, have a solution?
I got the basic code from Livedocs, written by Andreas Weber (of this
list?) code below. How would I modify it to accept "negative pixels"?
Thamks,
Niclas
---8<---
// 'snapshot'
import flash.display.BitmapData;
// create a clip with visual content
original = this.createEmptyMovieClip("orig",
this.getNextHighestDepth()); original.opaqueBackground =
0xFF0000; original.lineTo(100,100);
// create a BitmapData object with the same size var
myBitmapData:BitmapData = new BitmapData(original._width,
original._height);
// attach the Bitmap to a clip so that it will be rendered on
screen var copy:MovieClip = this.createEmptyMovieClip("cop",
this.getNextHighestDepth()); copy.attachBitmap(myBitmapData,
this.getNextHighestDepth()); copy._x = 300;
// take a 'snapshot'
myBitmapData.draw(original);
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com http://training.figleaf.com
ECM Systems Ltd, Ellifoot Park, Burstwick, East Yorkshire HU12 9DZ
Tel: 01964 672000
Fax: 01964 671102
Registered in England no. 01646471
The information contained within this email expresses the views of the sender and not necessarily
those of the company. It is private and confidential and may be legally privileged. It is intended
solely for those authorised to receive it. If you are not the intended recipient you are hereby notified
that any disclosure, copying, distribution or action taken in reliance on its contents is strictly prohibited
and may be unlawful. If you have received this email in error, please telephone us immediately on
01964 672000 or email a reply to highlight the error and then delete it from your system. This email may
contain links to web-sites, the contents of which ECM Systems Ltd have no control over and can accept
no responsibility for. Any attachments have been virus-checked before transmission; however, recipients
are strongly advised to carry out their own virus checking as ECM Systems Ltd do not warrant that such
attachments are virus-free. Please note that this email has been created in the knowledge that Internet
email is not a secure communications medium.
We advise that you understand and observe this lack of security when emailing us.
ECM Systems Ltd, Ellifoot Park, Burstwick, East Yorkshire HU12 9DZ
Tel: 01964 672000
Fax: 01964 671102
Registered in England no. 01646471
The information contained within this email expresses the views of the sender and not necessarily those of the company.
It is private and confidential and may be legally privileged. It is intended solely for those authorised to receive it. If you are
not the intended recipient you are hereby notified that any disclosure, copying, distribution or action taken in reliance on its
contents is strictly prohibited and may be unlawful. If you have received this email in error, please telephone us immediately
on 01964 672000 or email a reply to highlight the error and then delete it from your system. This email may contain links to
web-sites, the contents of which ECM Systems Ltd have no control over and can accept no responsibility for. Any
attachments have been virus-checked before transmission; however, recipients are strongly advised to carry out their own
virus checking as ECM Systems Ltd do not warrant that such attachments are virus-free.
Please note that this email has been created in the knowledge that Internet email is not a secure communications medium.
We advise that you understand and observe this lack of security when emailing us.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com