Thursday, August 14, 2008

Embedding PFM / PFB fonts

If you embed a PFM you will get this compiler error:
"Error: exception during transcoding: Font for alias 'AdLibICG_Font' with plain weight and style was not found at:"

That is because PFM is a supporting font file, it does not contain the real data. PFB does.
You don't need the PFM font, just embed the PFB font.

[Embed(source="../assets/AdLibICG.PFB", fontName="AdLibICG_Font", mimeType="application/x-font-truetype")]
private const EMBED_ADLIBICG:Class;

You must prov
ide the mimeType or else this compiler error occurs:
"Error: '../assets/AdLibICG.PFB' does not have a recognized extension, and a mimeType was not provided"

More info on PFM/ PFB here.

Embedding Fonts Bug

When embedding fonts do not name fontName or fontFamily the filename or the text will not appear if you set TextField::embedFonts to true. The filename is probably the device font name which can only be used if TextField::embedFonts is false.

All variations produce the same results:
[Embed(source="C:/WINDOWS/fonts/ARIAL.TTF", fontFamily="Arial")]

[Embed(source="C:/WINDOWS/fonts/ARIAL.TTF", fontName="Arial")]

[Embed(source="C:/WINDOWS/fonts/ARIAL.TTF", fontFamily="Arial", mimeType="application/x-font-truetype")]

[Embed(source="C:/WINDOWS/fonts/ARIAL.TTF", fontName="Arial", mimeType="application/x-font-truetype")]

TextField::text
TextField::htmlText

Test:
[Embed(source="../assets/ARIAL.TTF", fontName="Arial")]
private const EMBED_ARIAL:Class;

var tf:TextField = new TextField();
var format:TextFormat = new TextFormat("Arial");
addChild(tf);

tf.embedFonts = true;
tf.defaultTextFormat = format;
tf.text = "Test";

OR

tf.embedFonts = true;
tf.text = "Test";
tf.setTextFormat(format);

You will see no text.

Fonts Bug

TextField::defaultTextFormat does not work with TextField::htmlText

var tf:TextrField = new TextField();
var format:TextFormat = new TextFormat("Arial");
addChild(tf);

Does not work:
tf.embedFonts = true;
tf.defaultTextFormat = format;
tf.htmlText = "Test";

Works:
tf.embedFonts = true;
tf.defaultTextFormat = format;
tf.text = "Test";

For TextField::htmlText use :
tf.setTextFormat(format);

Thursday, August 7, 2008

Command Line Debugger Shortcut

After you type "run" in the "(fdb)" command prompt and executed the SWF file to debug, the debugger will load the SWF code. Typing "info sources" or "info file" will bring a list of source files loaded. See the "#' on filename.as#1, well that is a shortcut to the file. Another way to find files and their number shortcut is to:

(fdb) list a

Will bring up all functions that begin with the letter "a" and what file they are in and yes it is case sensitive.

To set a break point simply type:

(fdb) break #19:315

The 315 being the line number you want to break at.
Not sure want line to break at?
List the file like so:

(fdb) list #19

This will list the first 10 lines of code. Repeatedly hitting enter executes the last command without the passed in argument, so it will list the next 10 lines and so on. To skip to a certain location try:

(fdb) list #19:75

Which will jump to the 75th line of code.
Type "continue" to run your SWF. Check out the other options be typing "help" on the "(fdb)" prompt.

Another shortcut that can be used is just typing the first few letters of the command and not the whole command. For example "c" for "continue", "r" for "run", and "b" for "break". "help" displays the shortcuts next to the command in parentheses.

Enjoy!

Saturday, August 2, 2008

The Wheel

Always try to search for existing code, components, and libraries before venturing out to developer land.

Components
MinimalComps
Great for prototyping.

Yahoo! Astra

They actually have a lot of useful information.


Libraries
AS3CoreLib
Documentation
Contains a lot of useful functionality.

AS3Crypto

All crypto, all the time!

Alternative Crypto
labs.boulevart.be (A variety of encryption)
gsolofp.blogspot.com (MD5 and SHA1)


Occasionally Updated...