Advanced Arabic support workaround for Flash.

Hello everyone,

I have been working for some time now on the development of the Quran Searcher and Reciter as you may have noticed; basically it’s an online application that allows you to search for the occurrences of a particular word in the holy Quran and to recite Quran verses or chapters.

The Quran Searcher and Reciter is a Flash 8/ActionScript 2 based application with powerful features and a very beautiful user interface.

What I would like to share with you are some of the steps and bottlenecks we had to go through in order to reach the functionality we were looking for.

– The first problem we had to deal with was that Flash lacks real support of RTF (right to left) based languages like Arabic; this had an enormous impact on and was a big setback in our work.

An example of the consequences of this lack of support is that Flash wraps Arabic sentences in a character-based manner instead of the correct word-based fashion i.e it breaks in the middle of a word and wraps the reminder of this word to the next sentence instead of taking the whole word to the next line. This was a major problem as it could change the meaning of the verse!

Facing this harsh reality, we only had one way out: coding our own multiline Arabic text wrapper.

– The second major problem was the lack of direct database connectivity, Flash cannot directly connect to and retrieve data from a database, it needs to communicate via XML and PHP with the concerned mySQL database, this was fine for us till we faced the fact that in order to allow php to send the data via XML to Flash we have to change our default php encoding which means large unpredictable mess in the other php related sides of our host. We simply had to abandon this approach and to find a way to emulate database queries in pure ActionScript.

Having that done was the biggest and most important achievement in the development of this application.

What we basically came up with is a multidimensional array storing all of our elements, this had a positive side too since flash implements zlib compression to the data embedded in the swf file which reduced the size of data we needed to be loaded and consequently the loading time of the application.

– The third problem was searching Arabic text for a particular string; the problem really jumps in when the Arabic text stored in the database-like structure of our Flash application has diacritics (tashkeel) while the search string is diacritics-free. This was also a major issue and we had to come up with a somewhat hard solution: There has to be two fields for each verse, one with and one without diacritics. The search proceeds in the diacritics-free field and returns the ID of those verses containing the search word, then the with-diacritics field having the same ID would be retrieved and displayed.

Well, I don’t want to add more line to this article as I know you tend to get bored of looong readings, I will add more in a separate post later on.

Till then, enjoy this piece of art: The holy Quran Searcher and Reciter.

Leave a Reply