someone could tell me how I can zoom a Canvas, with transform.matrix, so that the content of the component fits into the parent container (application), either inward or outward
this function is called Zoomfit(), I have this code:
public function calcScaleToFitRatio(parentObj:DisplayObject, childObj:DisplayObject):Number{
var retVal:Number =开发者_StackOverflow社区 1;
if (null == childObj) {
return 1;
}
var containerRatio:Number = parentObj.height / parentObj.width;
var contentsRatio:Number = childObj.height / childObj.width;
var isContainerLarger:Boolean = (containerRatio > contentsRatio);
if (true === isContainerLarger) {
retVal = parentObj.width / childObj.width;
} else {
retVal = parentObj.height / childObj.height;
}
return retVal;
}
But I can't applied to matrix.scale();
Something like this would work, obviously replace stretchedCanvas
with name of your container you're stretching.
<mx:Canvas width="600"> <!-- outer container -->
<mx:Canvas id="stretchedCanvas"
scaleX="{IContainer(stretchedCanvas.parent).width/stretchedCanvas.width}"
scaleY="{IContainer(stretchedCanvas.parent).height/stretchedCanvas.height}"
>
</mx:Canvas>
</mx:Canvas>
精彩评论