Search code examples
apache-flexviewbox

How do I make the path scale to the container in Flex (View Box)?


I have the following markup:

<s:Group width="100%" height="100%"> 
    <s:BorderContainer borderWeight="3" borderColor="black" cornerRadius="5" width="100%" height="100%">
        <s:Path> 
            <s:stroke>
                <s:SolidColorStroke color="black" />
            </s:stroke>
            <s:data>M 14.153 14.788 C 13.856 15.25 13.161 15.628 12.612 15.628 L 0.766 15.628 C 0.216 15.628 -0.028 15.228 0.225 14.739 L 3.307 8.765 C 3.56 8.276 3.56 7.477 3.307 6.988 L 0.225 1.014 C -0.028 0.525 0.216 0.125 0.766 0.125 L 12.612 0.125 C 13.161 0.125 13.856 0.503 14.153 0.965 L 18.07 7.036 C 18.367 7.499 18.367 8.254 18.07 8.717 L 14.153 14.788 Z</s:data>
        </s:Path>
    </s:BorderContainer>
</s:Group>

I want the path in this container to resize based on the container. In SVG and Silverlight, there is the concept of "ViewBox" but I can't find that concept in Flex.

Setting the width and height to 100% kind of works, but it requires a lot of tinkering when you have a lot of paths. Plus, it doesn't behave exactly like you would want (try it out and resize your browser)


Solution

  • I found what I was looking for. AutoFitArea does exactly what I want:

    http://www.greensock.com/autofitarea/