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 http://www.adobe.com/products/flex/. To download the latest nightly build of the Flex Hero SDK, see http://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.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

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

  1. claudius says:

    scaleMode can be letterbox or stretch not scale

  2. dl says:

    Live example that you actually can see what it does would make more sense

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree