Skip to main content
Inspiring
Sep 28, 2012 11:34 PM UTC
Answered

Detecting RTL and LTR TLF text

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 is closed to new replies. Start a new post to keep the conversation going.
Jim WileyCorrect answer
Inspiring
Oct 1, 2012 11:18 PM UTC

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;

5 replies

M_E_Sepehr
Participating Frequently
Jun 17, 2018 11:31 AM UTC
sinious
Legend
Oct 1, 2012 8:58 PM UTC

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

Translate
Jim WileyAuthorCorrect answer
Inspiring
Oct 1, 2012 11:18 PM UTC

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;

Translate
sinious
Legend
Oct 2, 2012 1:21 PM UTC

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!

Translate