Setting the resize mode on a Spark BitmapImage object in Flex Gumbo

by Peter deHaan on December 14, 2008

in BitmapImage, BitmapImageResizeMode, FXG, beta1, needsSWF

The following example shows how you can set the resize mode on a Flex Gumbo BitmapO,age object by setting the resizeMode property to one of the static constants in the BitmapImageResizeMode class.

Full code after the jump.

To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see “Using the beta Gumbo SDK in Flex Builder 3″.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo">
    <s:layout>
        <s:VerticalLayout />
    </s:layout>

    <fx:Script>
        <![CDATA[
            import mx.events.IndexChangedEvent;
            import spark.primitives.BitmapImageResizeMode;

            protected function dropDownList_selectionChanged(evt:IndexChangedEvent):void {
                bitmapImg.resizeMode = dropDownList.selectedItem;
            }
        ]]>
    </fx:Script>

    <mx:ApplicationControlBar width="100%" cornerRadius="0">
        <mx:Form styleName="plain">
            <mx:FormItem label="resizeMode:">
                <s:DropDownList id="dropDownList"
                        prompt="Please select a resize mode:"
                        selectionChanged="dropDownList_selectionChanged(event);">
                    <s:dataProvider>
                        <s:ArrayList>
                            <fx:String>{BitmapImageResizeMode.NORMAL}</fx:String>
                            <fx:String>{BitmapImageResizeMode.REPEAT}</fx:String>
                            <fx:String>{BitmapImageResizeMode.SCALE}</fx:String>
                        </s:ArrayList>
                    </s:dataProvider>
                </s:DropDownList>
            </mx:FormItem>
            <mx:FormItem label="percentWidth:">
                <s:HSlider id="sliderH"
                        minimum="10"
                        maximum="90"
                        liveDragging="true" />
            </mx:FormItem>
            <mx:FormItem label="percentHeight:">
                <s:HSlider id="sliderV"
                        minimum="10"
                        maximum="90"
                        liveDragging="true" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <s:Group width="100%" height="100%">
        <s:BitmapImage id="bitmapImg"
                source="@Embed('assets/fx_appicon-tn.gif')"
                percentWidth="{sliderH.value}"
                percentHeight="{sliderV.value}"
                horizontalCenter="0"
                verticalCenter="0" />
    </s:Group>

</s:Application>

{ 4 comments… read them below or add one }

1 darron December 15, 2008 at 7:41 am

Note there’s currently a bug related to embedding a graphic when it’s scale-9 values are set. The resize mode of scale does not respect the scale-9 grid: http://bugs.adobe.com/jira/browse/SDK-17289

Reply

2 borf gordon December 15, 2008 at 10:06 am

Hi,
I would like to be able to implement support for partial downloads of large files in my app. (i.e. if the connection broke or user stopped the download partway etc)

It appears as if there are no solutions for being able to use content-range, range-request HTTP headers in either UrlStream w/UrlRequestHeader or anything in AIR/Flex/AS3? Is this true?

Any pointers appreciated as to how this could be implemented or if anyone knows of any existing libs/tools out there that do this.

Reply

3 Peter deHaan January 31, 2009 at 5:58 pm

darron,

Bug SDK-17289 was fixed in SVN revision #4612.

Peter

Reply

4 Peter deHaan May 29, 2009 at 11:21 am

Example updated to Flex SDK build 4.0.0.7378.

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can 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

Previous post:

Next post: