Skip to main content

ActionScript 2.0 Arabic Parsing v1.4

Update: a newer version available here

Well, I discovered some annoying bugs, all fixed in this version ..
As per my previous post here, I still recommend embedding fonts to avoid improper rendering.

ActionSctipt 2.0 version available here
ActionSctipt 3.0 version available here


  1. Dynamic TextField
  2. HTML Enabled TextField
  3. Pre-Assigned TextFormat
  4. Arabic Font

Recommended Properties:

  1. embedFonts: for proper rendering on Mac/Linux.


  1. data: for referencing original input string, use the data property ( instead of (TextField.text) where “utils” is an instance of StringUtils class.
  2. wrapFactor: optional reduction value (Mac only) for wrapping correction when using bi-directional text, possible values: .98 or less.
  3. htmlLines: array of spliced text block HTML lines.
  4. numLines: integer value of total text block lines.

Features Supported:

  1. Embedding Fonts (just put a dynamic textfield on-stage and select at least Basic Latin (95 glyphs) and Arabic (1088 glyphs) from the Character Embedding menu).
  2. Arabic Ligatures.
  3. Word Wrapping.
  4. Bi-Directional text.
  5. HTML Text.
  6. Loading External text on run-time.
  7. Windows/Mac/Linux support.
  8. Arabic enabled input fields using actionscript method (createArabicInput) with the help of javascript (arabicinput.js) beta

Features Not Supported:

  1. Arabic Diacritics (not necessarily for reading Arabic language in general, arabs are using diacritics mostly for writing Quran, and in that case diacritics are not the only missing feature, there’re many other ligatures cases in Arabic used for Quran writing).

Change List:

  1. Proper rendering for HTML bullet list (include the bullet character “•” in the Character Embedding menu).
  2. Optimized conditions for basic thorough loop.
  3. New properties for referencing text block lines (htmlLines, numLines).

Fixed Bugs:

  1. Multi-level HTML tags, for example:
      <a href="#"><font>text</font></a>
  2. Line-break determination on Mac.

Known Bugs:

  1. Improper wrapping for non-embedded fonts only on Mac when begin text line with non-Arabic characters or when using custom format HTML tags.

Here is an example works with this external XML file (with run-time resizing vs. wrapping):

download the above example here

Test files are available here using ASUnit Framework

11 thoughts to “ActionScript 2.0 Arabic Parsing v1.4”

  1. Thanks a lot for the library.This has made our life much easier. I want to use this but the problem that i am facing is total size of my application. I am using multiple flash swf that is loaded on-demand.Currently i have embedded font in all the movies and able to deliver arabic content.

    But I want to embed that font in the base movie and want others to share (with linkage) the embeded font.

    Do you see any issue with this?

    If possible, Can you please give a sample on the same?

  2. I am facing problem running this with linked font library and text box is showing me blank text.

  3. I can’t seem to change the fontsize of the text – am I missing something? I’ve tried with textformat as shown in the example, but I really want to use a stylesheet. No matter what I try, the text comes out the same small size. Here’s part of my code:

    var arabTxt:String = utils.parseArabic(myString);

    pageTitleTF = bg_pageTitle_mc.createTextField(“pageTitleTF”, bg_pageTitle_mc.getNextHighestDepth(), 0, 0, 1, 1);
    pageTitleTF.autoSize = “right”;
    pageTitleTF.embedFonts = true;
    pageTitleTF.styleSheet = appObj.getDisplayStyleSheet();

    pageTitleTF.text = “” + arabTxt + “”;

  4. sorry – the tags didn’t show up – that last line should have the proper tags around it

    p class=’pagetitle’



  5. @Edwin

    It works, here is an example:

    import TextField.StyleSheet;
    import com.xvisage.utils.StringUtils;
    var utils:StringUtils = new StringUtils();
    var style:StyleSheet = new StyleSheet();
    style.onLoad = function(done:Boolean) {
    	if (done) {
    		var styleObj:Object = style.getStyle(".arabic");
    		var tf:TextFormat = style.transform(styleObj);
    		output.htmlText = utils.parseArabic(myString, output, tf);

    Where “arabic.css” contains:

    .arabic {
    	font-family:Traditional Arabic; /*do not use single or double quotes around the font-family value ..*/

    And you need to use the most recent version available here

Leave a Reply

Your email address will not be published. Required fields are marked *