Skip to main content
Inspiring
September 28, 2012
Answered

Detecting RTL and LTR TLF text

  • September 28, 2012
  • 2 replies
  • 2707 views

Hi All,

I have set RTL in the preferences panel.

I need to test RTL and LTR 'direction' setting. It reports Null if it has not been explicitly set because it inherits the LTR.  I am trying to set LTR explicitly when I initialize the text and put it on the stage or at minimum, test for null and force it.

import flash.text.*;

import flash.text.TextFormat;

if (txtField.direction == null) {
        trace("It traces Null");// It traces Null 
        txtField.direction = LTR;
}

RangeError: Property direction value LTR is out of range
        at flashx.textLayout.property::Property$/defaultErrorHandler()
        at flashx.textLayout.property::EnumStringProperty/setHelper()
        at flashx.textLayout.formats::TextLayoutFormatValueHolder/setCoreStyle()
        at flashx.textLayout.formats::TextLayoutFormatValueHolder/set direction()
        at flashx.textLayout.elements::FlowElement/set direction()
        at fl.text::TLFTextField/set direction()
        at Code::Page1/textOverFlow()
        at Code::Page1/_Topic()
        at Code::Page1()

I have tried to add this:
import flashx.textLayout.formats;

Then it reports:

Page1.as, Line 16 1172: Definition flashx.textLayout:formats could not be found.

This topic has been closed for replies.
Correct answer Jim Wiley

thanks Sinious,

It got me real close. The first wouldn't work. I tried many variation on that one. Before and after your solid input.

The second/better did work when importing the .Direction too.

Was:

import flashx.textLayout.formats;

S/B:

import flashx.textLayout.formats.Directions;

2 replies

sinious
Legend
October 1, 2012

It is a constant, you must prefix it with the class or pass it as a string.

e.g.

txtField.direction = "rtl"; // string

or, better:

import flashx.textLayout.formats;

txtField.direction = Direction.RTL; // const

Jim WileyAuthorCorrect answer
Inspiring
October 1, 2012

thanks Sinious,

It got me real close. The first wouldn't work. I tried many variation on that one. Before and after your solid input.

The second/better did work when importing the .Direction too.

Was:

import flashx.textLayout.formats;

S/B:

import flashx.textLayout.formats.Directions;

sinious
Legend
October 2, 2012

Ah you're right. I'm glad you imported Direction and use the CONST RTL over the string version. Much better future proofing.

You're welcome and glad you got it fixed. Good luck!