We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Flash reading Arabic

Shopies asked
Medium Priority
Last Modified: 2012-05-07
Hi experts,
I have a flash components downloaded from one of the websites on the internet "Flashden.net" It's an image viewer and it's great. I want to integrate this FC with my CMS, so I linked that FC data source with a .php file and it worked just fine except that it doesn't read Arabic font. !! I tried all possible solutions like:
1. Add this : System.useCodePage=true; to the first line of the .as reading data file.
2. I tried all the unicode possibilities and I'm sure that my data is UTF8 compatible
3. I changed the first line of the .xml file into many different enicodes as well.

All of which didn't work with me and the best result I got is that the Arabic font turnes into "????????". Could anyone tell me what to do please?

You can download the source files form here:

Best Regards,
Watch Question

Top Expert 2009

Embed the arabic fonts.


I embeded the font as instructed in the first link but it didn't work. It gave me several errors when I came to export the file. Here is the code I used:
package {
import flash.display.Sprite;
import flash.text.Font;
public class FontFileGoudy extends Sprite
//here image/Goudy.ttf points to the font file relative to this file
[Embed(source="Arial.ttf", fontName="Goudy",fontWeight="bold", mimeType="application/x-font-truetype")]
private var font1:Class;
public function fontFile()
trace(Embedded font in loaded swf);
Font.registerFont(font1);//registers font
trace(registered font);

Open in new window

Top Expert 2009

Show the code on how you integrate with the CMS.

Also show the errors.


Okay, below you will see the PHP code:
And the errors I get when I export the .fla file into .swf is attached

FUNCTION update_xml()
		require "config.php";
		include_once "class.TemplatePower.inc.php";
		$tpl = new TemplatePower("components/product_viewer/items.xml");
		$tpl -> prepare();
		include_once 'ez_sql_core.php';
		include_once 'ez_sql_mysql.php';
		$ez = new ezSQL_mysql($config['db_user'],$config['db_password'],$config['db_name'],$config['db_server']);
		$ez->query("SET NAMES cp1256");
		IF($products_list = $ez->get_results("SELECT id,title,picture,details FROM album ORDER BY id DESC LIMIT 3",ARRAY_A))
		FOREACH($products_list AS $rows)
			$tpl -> newBlock("items");
			$tpl -> assign($rows);	
		$xmlfile = fopen("components/product_viewer/products.xml",'w+');		
		$xmlfile = fwrite($xmlfile,$tpl->getOutputContent());

Open in new window

Top Expert 2009
Unlock this solution and get a sample of our free trial.
(No credit card required)


I don't know what do you mean by the .as code? If you mean the FC .as file then you could find it below, but if you mean how do I embed the FC in my CMS then I just use an iframe.!! Does this answer your question?>
package com.ronnieswietek.productslider
	* Note: This file uses the free tweening engine: TweenLite. 
	* I have direct permission from Jack Doyle(Author of TweenLite to
	* distribute TweenLite, TweenFilterLite or TweenMax with any of my 
	* files on flashden). Please download it here if you have to:
	* http://blog.greensock.com/tweenliteas3/
	* Please view help.txt for information on how to setup a product slider
	// Import neccessary class files used in this product slider class
	import gs.TweenFilterLite;
	import gs.TweenLite;
	import gs.easing.Expo;
	import flash.display.*;
	import flash.events.*;
	import flash.display.BlendMode;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.net.navigateToURL;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	public class ProductSlider extends MovieClip
		// Private variables that should not be changed!
		// Everything set here is in the XML
		private var yPos					:Number;
		private var imageSpacing			:Number;
		private var slideTweenDuration		:Number;
		private var blurInDuration			:Number;
		private var blurOutDuration			:Number;
		private var newX					:Number = 0;
		private var currentIndex			:Number = 0;
		private var prevIndex				:Number = 0;
		private var product					:MovieClip;
		private var nextBtn					:MovieClip;
		private var prevBtn					:MovieClip;
		private var mainHolder				:MovieClip;
		private var titleField				:TextField;
		private var subtitleField			:TextField;
		private var source					:String;
		private var title					:String;
		private var subtitle				:String;
		private var itemURL					:String;
		private var useMouseWheel			:String;
		private var temp					:Object;
		private var data					:Array;
		private var xmlData					:XML;
		private var xmlList					:XMLList;
		private var xmlLoader				:URLLoader;
		public function ProductSlider(xml:String)
			// Load the XML
			xmlLoader						= new URLLoader();
			xmlLoader.load(new URLRequest(xml));
			xmlLoader.addEventListener(Event.COMPLETE, onComplete);
		private function onComplete(e:Event):void
			// Setup the movie clips for ease of access.
			mainHolder						= (parent as MovieClip).mainHolder;
			nextBtn							= (parent as MovieClip).next;
			prevBtn							= (parent as MovieClip).prev;
			titleField						= (parent as MovieClip).titletxt;
			subtitleField					= (parent as MovieClip).subtitletxt;
			// The data array contains all of the XML for easy access to the data anywhere.
			data							= new Array();
			xmlData							= new XML(xmlLoader.data);
			xmlList							= new XMLList(xmlData.item);
			yPos							= xmlData.attribute("yPosition");
			imageSpacing					= xmlData.attribute("imageSpacing");
			useMouseWheel					= xmlData.attribute("useMouseWheel");
			slideTweenDuration				= xmlData.attribute("slideTweenDuration");
			blurInDuration					= xmlData.attribute("blurInDuration");
			blurOutDuration					= xmlData.attribute("blurOutDuration");
			for (var i:int = 0; i < xmlList.length(); i++)
				// Loop through the xml and store it to the data array.
				temp						= new Object();
				source						= xmlList[i].@source
				title						= xmlList[i].@title;
				subtitle					= xmlList[i].@subtitle;
				itemURL						= xmlList[i].@itemURL;
				temp.source					= source;
				temp.title					= title;
				temp.subtitle				= subtitle;
				temp.itemURL				= itemURL;
			// Initiate the products!
		private function initProducts():void
			for (var i:int = 0; i < data.length; i++)
				// new ProductHolder() is the movie clip found in the library with linkage id of ProductHolder.
				// Each product will be inside one of these.
				product						= new MovieClip();
				product.x					= imageSpacing + (i * imageSpacing);
				product.id					= i;
				mainHolder.y				= yPos;
				var imgRequest:URLRequest 	= new URLRequest(data[i].source);
				var imgLoader:Loader 		= new Loader();
				product.buttonMode			= true;
				product.useHandCursor		= true;
				product.addEventListener(MouseEvent.CLICK, launchProductURL);
				if (useMouseWheel == "true")
					// if useMouseWheel is true in the XML you will be able to scroll the products with the mouse wheel.
					stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelEvent);
				imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
				imgLoader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
				imgLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
			// setup events for the arrows
			prevBtn.addEventListener(MouseEvent.CLICK, moveItemsLeft);
			prevBtn.addEventListener(MouseEvent.ROLL_OVER, navigationOver);
			prevBtn.addEventListener(MouseEvent.ROLL_OUT, navigationOut);
			prevBtn.buttonMode				= true;
			prevBtn.useHandCursor			= true;
			nextBtn.addEventListener(MouseEvent.CLICK, moveItemsRight);
			nextBtn.addEventListener(MouseEvent.ROLL_OVER, navigationOver);
			nextBtn.addEventListener(MouseEvent.ROLL_OUT, navigationOut);
			nextBtn.buttonMode				= true;
			nextBtn.useHandCursor			= true;
			titleField.mouseEnabled			= false;
			subtitleField.mouseEnabled		= false;
		private function navigationOver(e:MouseEvent):void
		private function navigationOut(e:MouseEvent):void
		private function launchProductURL(e:MouseEvent):void
			// This function gets called when you click on a product
			navigateToURL(new URLRequest(data[e.currentTarget.id].itemURL),"_blank");
		private function loadText(itemID:Number):void
			// Blur the text and change it to the correct text
			TweenFilterLite.to(titleField,blurInDuration,{blurFilter:{blurX:10, blurY:10, quality:3}});
			TweenFilterLite.to(subtitleField,blurInDuration,{blurFilter:{blurX:10, blurY:10, quality:3},onComplete:undoBlur});
			titleField.text					= data[itemID].title;
			subtitleField.text				= data[itemID].subtitle;
			//Slide the arrows over to accomidate subtitle field width change
			subtitleField.autoSize			= TextFieldAutoSize.CENTER;
		private function undoBlur():void
			// Now unblur the text
			TweenFilterLite.to(titleField,blurOutDuration,{blurFilter:{blurX:0, blurY:0, quality:3}});
			TweenFilterLite.to(subtitleField,blurOutDuration,{blurFilter:{blurX:0, blurY:0, quality:3}});
		private function moveItemsRight(e:MouseEvent):void
			currentIndex 					+= 1;
			if (currentIndex > (data.length - 1))
				// End of the product line
				currentIndex 				= (data.length - 1);
				// Slide mainHolder to show next product
				newX						= Math.round(currentIndex * (imageSpacing * -1));
		private function moveItemsLeft(e:MouseEvent):void
			currentIndex					-= 1;
			if (currentIndex < 0)
				// Beginning of the product line
				currentIndex = 0;
				// Slide mainHolder to show next product
				newX						= Math.round(currentIndex * (imageSpacing * -1));
		private function mouseWheelEvent(e:MouseEvent):void
			// slide the items by the mouse wheel
			if (e.delta > 0)
		private function initHandler(e:Event):void
			// After the image is done loading, set its alpha to 0 and set its registration point to the middle horizontally.
			e.target.content.alpha			= 0;
			e.target.content.x				= -e.target.content.width * 0.5;
		private function completeHandler(e:Event):void
			// After the init call, fade the image in.
		private function progressHandler(e:ProgressEvent):void
			// You can do what you like with this progress event. It just tells the status of loading image 0%-100%.
			//trace(e.bytesLoaded / e.bytesTotal);
		private function ioErrorHandler(e:IOErrorEvent):void
			trace("invalid source url");

Open in new window

Top Expert 2009

Can you link me to your site? I would like to see the ??? text.


I'm working locally. I gave you the complete source to download in my first post. Do you want me to attach the .php file?
Top Expert 2009

I need your .xml file.


Here it is. Please change the file extension into .xml
Top Expert 2009

I need the .xml file with the Arabic words, not English words so I can test. I do not know Arabic nor do I have Arabic fonts on my computer so I need you to provide me with both the font and the .xml with Arabic text.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.