The TextStyleClass - Movie Structure
The movie is basically empty except for the library, which contains all the Fonts classes, which we use for styling the text. From the library menu select "New Font.." (see figure on the left). Give a unique name to the font. This name will also be the class name for the font. Then select the font which you want to use. If you also want to use the font in "bold" and "italics", you need to create 3 different classes for each combination. After you have done this, click on the font symbol in the library and select "linkage" from the menu. Check the "Export for Actionscript" box and "ok". When you are asked to create a class automatically check "ok". Repeat this procedure for each font. We also need a UIScrollbar in the library. So drag the scrollbar from the component libary into the movie library.
NOTE:
In the stylesheet it is important to refer to the font not by its class name but by its actual name.
If we have a textfield on stage, which we want to use instead of creating a virtual textfield, we need to place it inside of a MovieClip. So we do that and have the MovieClip with textfield ready when we need it. You don't need to set any parameters like embedding fonts, since that is all done by the script and stylesheet.
To complete the movie section we already write the script to call the TextStyleClass as shown below. It is important here to place the instance on the timeline using addChild(). We need to import the class, create an instance and write some parameters, where we want to position the textfield and what are the sizes, background color and border. If we select 0 for border and background, they will not be created. We also have some lines, which are currently commented if we have a textfield in an MovieClip in the library. We need to create an instance of that MovieClip and fill the variable "tHold", which is otherwise null. If we select tw=0 and th=0 the textfield will be autosized. The individual functions are shown, which we need to call. as we have discussed it.
import biz.Flashscript.TextStyleClass; var fe:TextStyleClass = new TextStyleClass(); this.addChild (fe); /* Uncomment the lines below if you want to use a textfield from the movie library, which is located in a movieclip. */ //var tc:MovieClip = new MyTc(); //addChild(tc); /* Declaring that the movieclip is null. To use a movieclip from the library with a textfield delete null and uncomment tc. */ var tHold:MovieClip = null;//tc; // // parameters for the textfield // var tx:int = 50; var ty:int = 50; var tw:int = 500; var th:int = 400; var bdCol:uint = 0x333333; var bgCol:uint = 0xEAEAEA; fe.activateTextfield (tHold, tx, ty, tw, th, bdCol, bgCol); // // embedding fonts // fe.embedding = true; // // loading the XML file and stylesheet // var xmlFile:String = "EmbedFontAS3.xml"; var styleFile:String = "flashbody.css"; fe.loadFiles (xmlFile, styleFile);