Setting text alpha on a TextGraphic object in Flex Gumbo

The following example shows how you can set the text alpha on both device and embedded fonts on a Flex Gumbo TextGraphic control by setting the textAlpha style.

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/2008/11/01/setting-text-alpha-on-a-textgraphic-object-in-flex-gumbo/ -->
<FxApplication name="TextGraphic_textAlpha_test"
        xmlns="http://ns.adobe.com/mxml/2009">
    <layout>
        <BasicLayout />
    </layout>

    <Style>
        @font-face {
            src: url("assets/ARIAL.TTF");
            fontFamily: "ArialEmbedded";
            cff: true;
        }

        TextGraphic {
            fontSize: 24;
        }
    </Style>

    <HGroup left="10" top="10">
        <Label text="textAlpha:" />
        <FxHSlider id="slider"
                minimum="0.0"
                maximum="1.0"
                value="1.0"
                stepSize="0.1"
                valueInterval="0.1"
                liveDragging="true" />
    </HGroup>

    <Form id="form"
            horizontalCenter="0"
            verticalCenter="0">
        <FormItem label="device:">
            <Graphic>
                <TextGraphic id="deviceTextGraphic"
                        textAlpha="{slider.value}"
                        fontFamily="Arial"
                        fontLookup="device"
                        width="300">
                    <text>The quick brown fox jumped over the lazy dog.</text>
                </TextGraphic>
            </Graphic>
        </FormItem>
        <FormItem label="embeddedCFF:">
            <Graphic>
                <TextGraphic id="embeddedTextGraphic"
                        textAlpha="{slider.value}"
                        fontFamily="ArialEmbedded"
                        fontLookup="embeddedCFF"
                        width="300">
                    <text>The quick brown fox jumped over the lazy dog.</text>
                </TextGraphic>
            </Graphic>
        </FormItem>
    </Form>

</FxApplication>

View source is enabled in the following example.

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 text alpha on a TextGraphic object in Flex Gumbo

  1. Dale Fraser,

    I didn’t have time the other night, you’ll need to copy/paste the code and run it locally until I get time to create the SWF and upload it to my server.

    Peter

Comments are closed.