AS3.0 Snippets

October 31st, 2005 · 2 Comments


This Snippet allows you to embed fonts into a Flash AS3.0 Package. The original code was posted here .

[as]package
{

import flash.util.describeType;
import flash.display.MovieClip;
import flash.display.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\somefont.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);
}
}
}[/as]

How about donating a coffee, beer or even a round of beers for my efforts here? Thats around £2.50 for a coffee or a pint or about £10 for a round of beers. Cheers!

Tags: ActionScript 3 · Development · Snippets

2 responses so far ↓

  • 1 AS3 metadata 2 - Font embedding at FlashGen.Com .: blog :. // Nov 1, 2005 at 4:11 pm

    [...] Check it out here // Used for showing and hiding user information in the comment form function ShowUtils() { document.getElementById(“authorinfo”).style.display = “”; document.getElementById(“showinfo”).style.display = “none”; document.getElementById(“hideinfo”).style.display = “”; } function HideUtils() { document.getElementById(“authorinfo”).style.display = “none”; document.getElementById(“showinfo”).style.display = “”; document.getElementById(“hideinfo”).style.display = “none”; } [...]

  • 2 BitTubeBlog » Blog Archive » Correcting ActionScript 3 Example Errors // Jul 7, 2006 at 11:00 am

    [...] As I got a few moments to play with ActionScript 3, I thought now would update the Syntax involved in some earlier posts……. And also it would seem some of the examples in the ActionScript 3 Language reference. So here are some replacements you may need to use to get the examples to work from the ActionScript 3 Language Reference. [...]