Changing Character Set Embedding in a Flash Document

August 15th, 2008 by Rob

Here’s a little JSFL script that you can use to change the character-set embedding in all the input and dynamic TextFields in an entire Flash document. When you run it, it’ll pick the active document and pop up a prompt asking for the character-set IDs.

This is a pipe-delimited string of integers, so for one character set, say, “Basic Latin,” enter:

Character Embed Range Prompt

For more than one character set, say, “Basic Latin,” plus “Armenian,” enter:

Character Embed Range Prompt

This script uses the IDs from the UnicodeTable.xml file in C:\Documents and Settings\[username]\Local Settings\Application Data\Adobe\Flash CS3\en\Configuration\FontEmbedding. You can create your own character sets by copying or adding glyphRange elements.

For example, I wanted to extend the Basic Latin character set with some European characters. I simply copied the Basic Latin glyphRange element and gave it a new name and ID. Then I opened the charmap utility in Windows (C:\WINDOWS\system32\charmap.exe) and found the Unicode codes for the characters I wanted. The codes in charmap are in the format “0+0000.” Just change the “+” to an “x.” Since the characters in charmap are listed in order of their Unicode codes, you can use the first and last IDs of a range of characters and all those in between will be included. Here’s my “Basic Latin plus European” glyphRange:

<glyphRange name="Basic Latin Plus European" id="30" >
<!-- Ranges copied from "Basic Latin" -->
<range min="0x0020" max ="0x002F" />
<range min="0x0030" max ="0x0039" />
<range min="0x003A" max ="0x0040" />
<range min="0x0041" max ="0x005A" />
<range min="0x005B" max ="0x0060" />
<range min="0x0061" max ="0x007A" />
<range min="0x007B" max ="0x007E" />
<!-- New ranges -->
<range min="0x00C0" max="0x0259" />
<range min="0x1E80" max="0x1EF9" />
</glyphRange>

Download the script here.
Place the file in C:\Documents and Settings\[username]\Local Settings\Application Data\Adobe\Flash CS3\en\Configuration\Commands and run it from the “Commands” menu in Flash.

Update: If you get an error like this:

At line 1 of file "/Users/dan/Downloads/ReplaceTextFormat.jsfl":
TypeError: fl.findObjectInDocByType is not a function

there’s a quick fix. Find the file ObjectFindAndSelect.jsfl in en/Configuration/Javascript and edit the function FlashUtils_findObjectInTimeline, adding this in the first line of the body (around line 29):

if(!objTimeline)return;

This method performs a bunch of operations on that object but fails to check if it’s null first. According to a user in the comments on the livedoc entry for fl.findObjectInDocByType(), pngs in the fla timeline will cause objTimeline to be null. I tested it with a png and, by golly, it’s true. Thanks Dan!