Search code examples
actionscript-3textfieldarabic

Is there any way to add arabic text in as3?


I want to add Arabic text using AS3. But the problem I am facing is that once I assign text to textfield, the text gets reversed. Is there any way by which I can get this thing done. If there is any SWC that is required, please send me the link to that too.


Solution

  • You can use the TLFTextField

    var tlf:TLFTextField = new TLFTextField();
    tlf.defaultTextFormat = new TextFormat( "arialArabic" );
    tlf.antiAliasType = AntiAliasType.ADVANCED;
    tlf.direction = flashx.textLayout.formats.Direction.RTL;
    
    tlf.text = "هلو ورد!";
    

    Or if you need to use the standard TextField then you'll need to look into using a library like the one below to correct the text :

    https://github.com/SaffronCode/UnicodeRTL

    eg:

    textField.text = UnicodeStatic.convert("هلو ورد!");