I have SampleComponent
:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
resizeMode="scale">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Image source="@Embed('assets/images/soLogo.jpg')" width="100%" height="100%" scaleMode="stretch" />
</s:Group>
It features just an image that stretches to fill the whole component area, the component resizeMode
is set to "scale".
I put this component into an application with the below code:
<local:SampleComponent id="sample"
width="100%"
height="{sample.width * 0.2961165048543689}" />
The width is set to 100% of the applications width. In my attempt to scale the component correctly I set the height to a percentage of the width.
When the application window is resized, it looks like this:
The last image here is my problem, it exceeds the bounds of the application.
- How can I have the component resize without exceeding the bounds of the parent container?
- Is there a more correct way of scaling components?