To counteract this I've written and rewritten a double function which resizes your clip based on the visible area rather than what flash considers the bounds. Here it comes...
//Returns width or height you need to use to resize an MC containing a mask.
//include visibleOrigSize if you know it to cut down on processing power
function maskCompensate(mc:MovieClip, prop:String, desiredSize:Number, visibleOrigSize:Number){
var oX=mc._xscale;
var oY=mc._yscale;
mc._xscale=mc._yscale=100
if(visibleOrigSize==undefined){
var visibleOrigSize=(prop=="_width" ? getVisibleBounds(mc).width : getVisibleBounds(mc).height)
}
var diff = mc[prop]-visibleOrigSize
var percentIncrease = desiredSize/visibleOrigSize
mc._xscale=oX
mc._yscale=oY
return(desiredSize+diff*percentIncrease)
}
import flash.display.BitmapData;
function getVisibleBounds(mc){
var myBitmapData:BitmapData = new BitmapData(mc._width,mc._height);
myBitmapData.draw(mc);
bounds = myBitmapData.getColorBoundsRect( 0xFFFFFFFF, 0xFFFFFFFF, false );
bitmapData.dispose();
return(bounds)
}
//sample usage:
this._width = maskCompensate(this,"_width",500)
this._height = maskCompensate(this,"_height",300)
No comments:
Post a Comment