Setting the scale mode on a Spark Image control in Flex Hero

In a previous example, “Setting the fill mode on a Spark Image control in Flex Hero”, we saw how you could set the fill mode on a Spark Image control in Flex Hero by setting the fillMode property to one of the static constants in the mx.graphics.BitmapFillMode class.

The following example shows how you can set the scale mode on a Spark Image control in Flex Hero by setting the fillMode property to “scale” and setting the scaleMode property to one of the static constants in the mx.graphics.BitmapScaleMode class.

The following example(s) require Flash Player 10 and the beta Adobe Flex Hero SDK. To download the Adobe Flash Builder 4 trial, see www.adobe.com/products/flex/. To download the latest nightly build of the Flex Hero SDK, see opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2010/09/04/setting-the-scale-mode-on-a-spark-image-control-in-flex-hero/ -->
<s:Application name="Spark_Image_scaleMode_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx">
    <s:controlBarContent>
        <s:Form>
            <s:FormItem label="scaleMode:">
                <s:DropDownList id="ddl" selectedItem="letterbox">
                    <s:dataProvider>
                        <s:ArrayList source="[letterbox,scale]" />
                    </s:dataProvider>
                </s:DropDownList>
            </s:FormItem>
        </s:Form>
    </s:controlBarContent>
 
    <s:Image id="img"
            source="assets/pattern_149.gif"
            fillMode="scale"
            scaleMode="{ddl.selectedItem}"
            backgroundColor="black"
            backgroundAlpha="0.1"
            left="20" right="20" top="20" bottom="20" />
 
</s:Application>

This entry is based on a beta version of the Flex Hero SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex Hero SDK.

2 thoughts on “Setting the scale mode on a Spark Image control in Flex Hero

Comments are closed.