HTML Entities in Flash
May 15th, 2009For whatever reason there html text in flash does not support too many of the named characters. Any time I’m loading in an external file I’m constantly forgetting about that and things like bullets and emdashes don’t show up. I finally broke down and went to: http://www.evolt.org/entities and built a script to take care of this nagging problem. It will convert most of the standard name based entities to their numeric counterparts.
You can grab the file here.
December 6th, 2009 at 2:26 am
Hi!
To increase performance of your code you can use more lightweight script:
[code]package
{
public class Test
{
private static const entitys:Object =
{
quot: 34, amp: 38, apos: 39, lt: 60, gt: 62,
iexcl: 161, cent: 162, pound: 163, curren: 164
}
// etc…
public static function replace(text:String):String
{
return text.replace(/&(.+?);/gi, nameToCode);
}
private static function nameToCode():String
{
return “&#” + entitys[arguments[1]] + “;”;
}
}
}[/code]