I’m learning AS3 with Flex Builder 2, and have run into all sorts of difficulties when trying to embed a font so that a group of textfields will display correctly when they are tweened. There are a number of examples posted across the web which apparently work fine for other people, but I’ve tried them unsuccessfully. Perhaps this is because other people are using the Flash 9 alpha and it works differently in Flex, though I don’t know why that should be.
For example, with this code I receive an error that says "Unable to resolve “C:WindowsFontsARIAL.TTF for transcoding” even though the file exists in that location.
package {
import flash.utils.describeType;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.AntiAliasType;
public class Test extends MovieClip {
// be sure this is pointing to a ttf font in your hardrive
[Embed(source="C:\WINDOWS\Fonts\ARIAL.ttf", fontFamily="foo")]
public var bar:String;
public function Test() {
var format:TextFormat = new TextFormat();
format.font = "foo";
format.color = 0xFFFFFF;
format.size = 130;
var label:TextField = new TextField();
label.embedFonts = true;
label.autoSize = TextFieldAutoSize.LEFT;
label.antiAliasType = AntiAliasType.ADVANCED;
label.defaultTextFormat = format;
label.text = "Hello World!";
addChild(label);
}
}
}
Could someone please post a working example?
Fingers