Copy link to clipboard
Copied
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.
1 Correct answer
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;
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied

