I'm still in the process of making a Hebrew version of one of our client's sites. As I cannot wait for the next version of Flash to hopefully solve all my right-to-left problems I've written some workaround tools for myself.
Tool number one is an addition to the TextField object that will reformat a bidirectional text so it can be read correctly. The task is to check in each line how many words do fit in and then make a manual linefeed. Unfortunately i have to use the not very precise getTextExtent() method. But from what I can see with my non-existing knowledge in Hebrew this works for texts that are not nested too deep.
Tool number two plugs into inputfields and tries to make them handle Hebrew input. This means taking control of the cursor and setting it to the left or right of a letter, depending on its origin. It will not do the fancy cursor acrobatics that you see in native HTML input fields, but it should be able to handle standard things like names, adresses or one-liners. It also tries to handle text that gets pasted in via the clipboard. This is harder than it looks because you have to find out first which part of the text has changed. Then you have to apply the flipping algorithm to this part, because internally the system stores any text in logical order. At least that's what Windows XP does. This is where you can help me and check if pasting works correctly with your OS. There are some cases where the routine will fail: if you select a part of the text and replace it with some shorter text it will do strange things. What also fails is copying a Hebrew text from this input field into another application. As flash doesn't have access to the clipboard I cannot re-flip the text after it has been copied.
Here you can test the input field. If you don't have Hebrew support in your system, you will not see any special effects - why are you reading until here anyway?
In case you experience any no-nos or bugs - send me a mail or use the comments - perhaps it can be fixed.
I would call this a beta, but if you want to experiment with it yourself or expand it to a version that also handles arabic chars here is the download link: Flash Hebrew Tools 1.0 But don't ask me to explain to you how it works. And don't expect it to work at all.
Should this script against my better knowledge make you so happy that you feel bad to take it for free I can offer you two ways to relieve yourself: there is my Amazon wishlist and there is PayPal.
Kudos for the job you are doing. This is pretty much the world we're living in on a daily basis for the past four years or so. A rare bunch of friends of mine have also been working on trying to solve the defect like yourself, but the problem in most cases is that it's never 100% and won't pass. I really appreciate what your doing.
As for a quick bug report:
1. The backsapce doesn't work.
2. When I insert an english word, the first letter in the sentence gets cut off.
3. If you type a number in Hebrew and want to have an english word after it, the word will appear before the number.
4. Quotation marks don't seem to work.
I'm not sure if it's related but since viewing this page my Pentium4 is almost completely stuck. Are you running some CPU intetensive procedures in there or it just me?:)
Anyway, if you need someone to test it now and then you have my email and I'll be glad to help in any way I can. Just let me know.
Thanks for the check Amir. Looks like I'll have to work on it further. For this number problem - perhaps you can add a line in the comments which behaves wrong.
The speed thing sounds strange. Does this happen with long texts or all the time? There is nothing going on except the listener for "onChanged".
Not quite sure what you meant by "perhaps you can add a line in the comments which behaves wrong". If you meant an example then if I want to have:
english 90210 Hebrew
(typing from right to left of course)
Then the result will be:
90210 english Hebrew
The moment you start typing the english word following the number it starts before the number. The backsapce isn't working only with the Hebrew text but seems to be working with English text.
The punctuation seems to work well so far. As for the CPU problem I'm not sure. After spending more than 5 minutes in his page and running some tests in the text field everythign starts moving really slow and it takes about a second before can see the text I'm typiing now. I have nothing else running other than Outlook and te usuall stuff.
The first letter in the sentence sems to get cut off the minute I switch to type in English :/
Now I know what you mean. Oops - I thought that's the way it is done. I guess that can be corrected. I will study the behavior of the HTML input field again.
The thing is there isn't really one way of writing it. It depends on the context of what you are writing. If I write to someone in Hebrew "I bought Flash 6" than the number will appear after the English word. However, I can also say something like: "Make sure you ring Macromedia up and buy 13 Flash MX and 10 Dreamweaver MX". In which case I'll have to put the number before the English word.
At the moment, once you have an English word you can't seem to get a number after it, meaning to its left. It will always appear to its right, no matter what language you use. After seeing other made-up solution to the RTL defects in Flash I can honestly tell you Mario that they never offer a 100% correct experience and act a bit different. I believe that the avarage user's patience threshold is much lower than that of any fellow developer who might test it. Once it starts behaving a bit different than what user expect they won't bother with it and will just walk away.
I don't mean to be negative, but after seeing others non-Hebrew speaking flash developers and Israeli developers as well trying to offer a workable solution and can't make it work 100% I at least came to conclusion that the solution lies elsewhere. Developers should work with a tool, not try and figure out how to fix it.
For some reason, on my Mac (osx 10.2.6, running Safari as the browser), your text box won't even let me switch to Hebrewto type aynthing, althugh I am able to type Hebrew in other places.
Since the full flash MX on mac won't let you switch to Hebrew (althugh Hebrew is part of the system), it is probably due to a Macromedia bug and not to anything you did.
btw, if i switch to Hebrew and then go to the text box, the keyborad goes back to English. not very helpful...
It didn't work for me at all.
I'm running XP, with English and Hebrew as the available languages.
It wouldn't type for me in Hebrew mode.
In MOzilla, the following code was on the screen:
TYPE="application/x-shockwave-flash" LUGINSPAGE="http://www.macromedia.com/go/getflashplaye
But I tested it in IE also, and no dice.
Hi Mario.
In addition to what was mentioned:
Hebrew number Hebrew - gets messed up,
Hebrew English Puncuation - also...
Hebrew number Puncuation - also...
Keep up the good work, remember what FLEM did to the MX event model...
Hi Mario
Cheers for your work. I have tried this approach way back in the 98 era and it worked ok for a while, but if you want to use some html tags or English and hebrew at the same line you are in trouble.
I have attacked this issue a little differently. I decided to drop the embeded fonts and stick to Unicode system fonts, as I found that when I use unicode and external files, the letters are fliped correctly in hebrew and most of the warp done is reasonable (as long as there are no periods or commas at the end of a warpped line). I used align to right and it works reasonably
To solve the commas and the periods issue I have added a small routine that searches for these characters and a space (" .") and adds unicode directional characters (String.fromCharCode(0x200F)) before and after the space. I don't know how I came to this funcky idea, but it seems to work fine with window XP,2000, win98 hebrew enabled.
I still have problems with win98 hebrew. For some odd reason, In some cases the texts are still flipped. Any ideas?
Also, the align right is not completly aligned - an annoying macromedia bug
Note: its the first time I publish this knowledge and I did not document it properly yet. Do you know of anybody else trying my approach.
Actually I have got a problem to get the right program to able me to read the Arabic texts through the website in general. I will be grateful if you could help me with this. My computer is iMac OSX, version: 10.2.6
I would love to get ahold of the fla that created the swf that is on the site. I am having problems with the exact makeup of the input field's properties to make my swf look exactly like yours does.
I like what u did very much ... i am trying to do the same thing using SwishMax ... everything works .. but i cant type from right to left in an input text ...
thats my only problem ..... when i try it, it types the word upside down ...
in your text area it doesnt happend ... but you cant use the backspace ... all you can do to delete something is the mark it with the mouse and then to delete it .....
Is there anyway i can use it in SwishMax ...
sites like ynet.co.il that use flash make linux crash.
If I don't install falsh player, it doesn't.
tried several browsers, and linux distros
can anyone help?
I just installed flash 8. I was sure they would solve the RTL direction problem in this version but for some reason they do not want to solve this and enable us Hebew and Arabic users to use flash for our web sitees
Almost all good! But the problem for me is that I'm using Yiddish, which contains vowels under alef, etc...
And if you test it, you'll see that the vowel is written on the right of the consonant, not under it. By the way, it works with simple input or dynamic text fields of Flash MX, but the problem is with the English letters and punctuations marks mixed together with Yiddish and also with text selection. What a pain!