尝试使用 Colin Moock hack:http ://www.moock.org/blog/archives/000292.html
public class SomeMaskedControl extends UIMovieClip
{
protected var mc:MaskedMC;
public function SomeMaskedControl()
{
super();
mc = new MaskedMC();
addChild(mc);
}
public function getVisibleHeight (o:DisplayObject):Number {
var bitmapDataSize:int = 2000;
var bounds:Rectangle;
var bitmapData:BitmapData = new BitmapData(bitmapDataSize, bitmapDataSize, true, 0);
bitmapData.draw(o);
bounds = bitmapData.getColorBoundsRect( 0xFF000000, 0x00000000, false );
bitmapData.dispose();
return bounds.y + bounds.height;
}
override public function get height():Number
{
return getVisibleHeight( mc );
}
}
但我不喜欢这种方式。如果您可以将遮罩创建为 MovieClip,并设置实例名称,则在应用程序中您可以获取 mask.height 并替换 UIMovieClip 高度:
public class SomeMaskedControl extends UIMovieClip
{
protected var mc:MaskedMC;
public function SomeMaskedControl()
{
super();
mc = new MaskedMC();
addChild(mc);
}
override public function get height():Number
{
return mc.maskMC.height;
}
}