Creating blinking text on a Spark RichText control in Flex 4

The following example shows how you can create a blinking text effect on a Spark RichText control in Flex 4 using a simple property animation with the Animate and SimpleMotionPath classes to tween the alpha property.

I’d like to dedicate this post to the two people that searched for this on my blog (who may be the only people to want to bring back the old HTML blinking text effect).

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

For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2010/08/13/creating-blinking-text-on-a-spark-richtext-control-in-flex-4/ -->
<s:Application name="Spark_RichText_blink_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:layout>
        <s:HorizontalLayout horizontalAlign="center" verticalAlign="middle" />
    </s:layout>
 
    <fx:Declarations>
        <s:Animate id="fader"
                duration="500"
                repeatBehavior="reverse"
                repeatCount="0"
                target="{lbl}">
            <s:SimpleMotionPath property="alpha"
                    valueFrom="1.0" valueTo="0.0" />
        </s:Animate>
    </fx:Declarations>
 
    <s:Label id="lbl"
            text="BLINKING TEXT, I HATE YOU!"
            color="red"
            fontSize="32"
            creationComplete="fader.play();" />
 
</s:Application>

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

7 thoughts on “Creating blinking text on a Spark RichText control in Flex 4

  1. This is great. This post has made me research a bit about the Animate class which I have never used.
    I normally use TweenLite for this but if we can do it with the SDK it’s much better.

    Thanks for the post.

  2. Peter
    Sorry this is off topic but I recall reading one of your posts that described the technology and techniques behind your site.

    I can no longer find this post and can’t think of a keyword to search by.

    Can you help?

    Thanks
    Mark.

  3. Oops sorry for the overlap there but while I’m back I’d like to say Peter what an absolutely brilliant resource your website is for flex development.

    Over and out!

    Mark.

  4. Hi,
    iam searching to set the font color of an richtext into as3.
    Does someone know how i can do that ?
    for example, i want to write someething like this : “RichtextID.fontcolor = #ff0000 ;”

Comments are closed.