This tutorial will cover how to make a textfield fade out using actionscript only. If you've ever tried to make a textfield fade out using the textfield._alpha property, you probably did something wrong, and your textfield probably just went from alpha 100 to alpha 0. That's because you need to embed fonts to make it work.
Fading text is a great effect in movies and games. In games, you may want to fade a message or a score or something. It is very inconvenient to have to make a symbol for each new message or score that you need. In my most recent game, Final Tank, I used fading text a lot. Here is how to do it.
First, you need to add a new font symbol to the library. On the upper right corner of the library, there is a drop down menu. Click it and select 'New Font'.
Its in the same place as New Video
In the drop down menu that says "Font", select the font of your textfield. In the text area labeled "Name", type Font1 . If you want the font to be bold or italicized, check the boxes. When everything is good, click ok. Right click on the Font in the library and select Linkage. Click on 'Export for Actionscript' and make sure that the identifier is Font1.
Now for some action. script that is.
createTextField("textfield", 1, 275, 200, 200, 25);
// creates a textfield
var fmt:TextFormat = new TextFormat();
fmt.font = "Font1";
//creates a text format and associates the font in the library with it.
textfield.embedFonts = true;
//tells the textfield to include fonts in the library.
textfield.text = "alpha fade out";
//sets the text of the textfield.
textfield.setTextFormat(fmt);
//sets the format of the textfield
onEnterFrame = function () {
textfield._alpha -= 5;
};
Thats all, its pretty simple.
I hope this tutorial helped.