Setting the scale mode on an Ellipse object stroke in Flex Gumbo

The following example shows how you can set the scale mode on an Ellipse object’s stroke object by setting the scaleMode property to one of the static constants in the LineScaleMode 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"?>
<!-- http://blog.flexexamples.com/2009/01/10/setting-the-scale-mode-on-an-ellipse-object-stroke-in-flex-gumbo/ -->
<Application name="Ellipse_stroke_scaleMode_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <ApplicationControlBar dock="true">
        <Form styleName="plain">
            <FormItem label="scaleMode:">
                <ComboBox id="comboBox" selectedIndex="1">
                    <dataProvider>
                        <Array>
                            <String>{LineScaleMode.NONE}</String>
                            <String>{LineScaleMode.NORMAL}</String>
                            <String>{LineScaleMode.HORIZONTAL}</String>
                            <String>{LineScaleMode.VERTICAL}</String>
                        </Array>
                    </dataProvider>
                </ComboBox>
            </FormItem>
            <FormItem label="scaleX:">
                <HSlider id="xSlider"
                        minimum="1"
                        maximum="5"
                        value="1"
                        tickInterval="1"
                        liveDragging="true" />
            </FormItem>
            <FormItem label="scaleY:">
                <HSlider id="ySlider"
                        minimum="1"
                        maximum="5"
                        value="1"
                        tickInterval="1"
                        liveDragging="true" />
            </FormItem>
        </Form>
    </ApplicationControlBar>

    <Graphic>
        <Ellipse id="ellipse"
                width="80"
                height="60"
                scaleX="{xSlider.value}"
                scaleY="{ySlider.value}">
            <stroke>
                <SolidColorStroke id="lineStroke"
                        scaleMode="{comboBox.selectedItem}"
                        weight="10" />
            </stroke>
        </Ellipse>
    </Graphic>

</Application>

You can also set the scaleMode property using ActionScript, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/01/10/setting-the-scale-mode-on-an-ellipse-object-stroke-in-flex-gumbo/ -->
<Application name="Ellipse_stroke_scaleMode_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <Script>
        <![CDATA[
            import mx.events.ListEvent;

            private function comboBox_change(evt:ListEvent):void {
                lineStroke.scaleMode = comboBox.selectedItem.toString();
            }
        ]]>
    </Script>

    <ApplicationControlBar dock="true">
        <Form styleName="plain">
            <FormItem label="scaleMode:">
                <ComboBox id="comboBox"
                        selectedIndex="1"
                        change="comboBox_change(event);">
                    <dataProvider>
                        <Array>
                            <String>{LineScaleMode.NONE}</String>
                            <String>{LineScaleMode.NORMAL}</String>
                            <String>{LineScaleMode.HORIZONTAL}</String>
                            <String>{LineScaleMode.VERTICAL}</String>
                        </Array>
                    </dataProvider>
                </ComboBox>
            </FormItem>
            <FormItem label="scaleX:">
                <HSlider id="xSlider"
                        minimum="1"
                        maximum="5"
                        value="1"
                        tickInterval="1"
                        liveDragging="true" />
            </FormItem>
            <FormItem label="scaleY:">
                <HSlider id="ySlider"
                        minimum="1"
                        maximum="5"
                        value="1"
                        tickInterval="1"
                        liveDragging="true" />
            </FormItem>
        </Form>
    </ApplicationControlBar>

    <Graphic>
        <Ellipse id="ellipse"
                width="80"
                height="60"
                scaleX="{xSlider.value}"
                scaleY="{ySlider.value}">
            <stroke>
                <SolidColorStroke id="lineStroke"
                        weight="10" />
            </stroke>
        </Ellipse>
    </Graphic>

</Application>

This entry is based on a beta version of the Flex Gumbo 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 Gumbo SDK.

2 thoughts on “Setting the scale mode on an Ellipse object stroke in Flex Gumbo

    1. @Mauricio,

      It takes me a long time to create and upload SWFs and link them to the site, and thankfully most of these examples are very easy for people to copy and paste into Builder and see the results themselves if they are curious enough.

      Peter

Comments are closed.