Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Detecting RTL and LTR TLF text

Contributor ,
Sep 28, 2012 Sep 28, 2012

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.

TOPICS
ActionScript
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Oct 01, 2012 Oct 01, 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;

Translate
LEGEND ,
Oct 01, 2012 Oct 01, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 01, 2012 Oct 01, 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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2012 Oct 02, 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 17, 2014 Jan 17, 2014

Follow-up

I implemented it and I wanted to point out a few typos - details.

tempCC.ccTextMC.Label - is the text field. The If statement below is testing if the language is Arabic (ar) or Hebrew (he)

Code

import flashx.textLayout.formats.Direction;

    if (Lang ==  "ar" || Lang ==  "he") {

     tempCC.ccTextMC.Label.direction = Direction.RTL;

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 17, 2018 Jun 17, 2018
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines