as3 Flash: dynamic gradient text

Posted on 2011-10-20
Last Modified: 2012-05-12
i want to make dynamic gradient text in my flash swf.

the way i have been playing with is this:
i create two layers on my time line
the top layer has a static text textbox on it
on the bottom layer i have a gradient box

in the text box i type some letters-  then i right click on the layer with the textbox and select mask
This produces the desired effect.
now the problem…
 i want to dynamically add text to this text box.
to do so i have to switch the text box type to dynamic and in my code i
set my textbox.text = "mytext";

the result is not consistent.
I’ve tried other thing like applying the mask in code. I’ve tried cacheAsBitmat for both my textfield and the gradient box and setting the mask gradiantbox.mask = textfield which also doesn’t work for me. I’ve also tried adding the textbox through code.
 every way that i have tried i get inconsistent results. sometime the text seems to disappear! sometimes the mask does not apply. what the heck am i doing wrong?!  : )
any help would be appreciated.

Thanks : )

Question by:conagraman
    LVL 29

    Expert Comment

    Please can you create a sample FLA file in CS4 format and attach to your post
    LVL 10

    Accepted Solution

    Thank you for the comment.
    I was able to get it. i really don’t know what it is that I was doing wrong. I built a file to build myself examples. I’m sure you don’t need it dgofman but I am posting it for anyone who might need it in the future. The file gives three examples. You can see my progression with the three examples.
    The first example is a text box and a gradient box in a movie clip.
    The second has the textbox in a movie clip and the gradient is in a movie clip.
    The third is a movie clip that contains a movie clip with a gradient box and a textbox.
    The third one is the one that I really was trying to create. The purpose was to be able to not have to add the objects at runtime and to be able to not have to add the filters at runtime.

    Thanks again for the comment dgofman
    LVL 10

    Author Comment

    that last swf was the wrong one here is the right swf textGradient4.swf
    LVL 10

    Author Closing Comment

    adding for future users

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    Read about why website design really matters in today's demanding market.
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now