Skip to main content
Participant
October 11, 2010
Answered

Text direction not working in pure AS3 project compiled with Flash CS5

  • October 11, 2010
  • 1 reply
  • 2364 views

Any idea why this does not work? The text direction remains LTR no matter what I do. I tried moving around at what point the text is set with no luck.

The only difference I get is this text:
Registered TRADEMARK<font face="Lucida Sans Unicode">®</font>

Is rendered as:
®Registered TRADEMARK

protected function configureText(title:String):void
{
     this.textField = new TLFTextField();
     this.textField.autoSize = TextFieldAutoSize.LEFT;
     this.textField.mouseChildren = false;
     this.textField.mouseEnabled = false;
     this.textField.selectable = false;
     this.textField.wordWrap = false;
    
     this.textField.htmlText = title;
    
     var format:TextLayoutFormat = new TextLayoutFormat();
     format.color = this.defaultTextColor;
     format.direction = Direction.RTL;
     format.fontFamily = "Arial";
     format.fontSize = this.size - 4;
     format.textAlign = TextAlign.RIGHT;
    
     this.textField.textFlow.hostFormat = format;
     this.textField.textFlow.flowComposer.updateAllControllers();
    
     this.addChild(this.textField);
}

Compiled with Flash CS5 11.0.2.489

This topic has been closed for replies.
Correct answer robin_briggs

Characters that are part of left to right scripts are set by default left to right. Characters that are part of right to left scripts (e.g., Arabic or Hebrew) are set right to left. Characters such as punctuation (or the registered trademark symbol) are set according to the default direction. Therefore in your example the registered trademark symbol comes out on the other side because its set rtl. Had you set Arabic or Hebrew text, it would come out right to left. The default direction is also used for figuring out whether the indent, for example, should go on the left or the right.

Did you want your English text to come out right to left? What effect are you trying to get?

Thanks,

- robin

1 reply

robin_briggsCorrect answer
Adobe Employee
October 12, 2010

Characters that are part of left to right scripts are set by default left to right. Characters that are part of right to left scripts (e.g., Arabic or Hebrew) are set right to left. Characters such as punctuation (or the registered trademark symbol) are set according to the default direction. Therefore in your example the registered trademark symbol comes out on the other side because its set rtl. Had you set Arabic or Hebrew text, it would come out right to left. The default direction is also used for figuring out whether the indent, for example, should go on the left or the right.

Did you want your English text to come out right to left? What effect are you trying to get?

Thanks,

- robin

Participant
October 12, 2010

Oh, well that is awesome. I was worried I'd have to markup any inline text direction switching. I thought for some reason setting the text direction to RTL would reverse any and all text. What you said makes perfect sense. I was testing with English characters because I have a hard time being able to tell if Hebrew is being displayed properly. Thanks for the help.