For future search purposes here's a litlle AS3 function to clone a
snapshot of any mc into a new mc:
[as3]
//
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.geom.Matrix;
//
function cloneMC(mc, padding){
var bounds:Object = this.getBounds(mc);
var offset_y:Number =padding
var offset_x:Number =padding
var w:Number = bounds.width +offset_x
var h:Number = bounds.height +offset_y
bounds.x=bounds.x-offset_x/2
bounds.y=bounds.y-offset_y/2
var holder:Bitmap=new Bitmap()
var bitmap:BitmapData = new BitmapData(w, h, true, 0x00000000);
holder.bitmapData=bitmap
this.addChild(holder)
holder.name=mc.name+this.getChildIndex(holder);
bitmap.draw(mc, new Matrix(1,0,0,1,bounds.x*-1,bounds.y*-1));
holder.x= bounds.x+mc.x;
holder.y= bounds.y+mc.y;
return holder
}
mcCopy=cloneMC(test_mc,100);
[/as3]
You can supply the function with a padding argument which will place a
margin of transparent pixels around your new MC - this is useful for
applying fx to the image at a later point in time.
Still couldn't get the reg point in exactly the same spot for both MC's
especially with text so I gave up as I don't need it for my purposes -
but if someone wants to add to it then go ahead.
Hope it's useful to someone.
Cheers
M
_______________________________________________
[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