Flash reading Arabic

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:
http://www.shopies.com/flashden_xml-product-viewer-as3_38951.zip

Best Regards,
ShopiesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TanLiHaoCommented:
Embed the arabic fonts.
0
ShopiesAuthor Commented:
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

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

TanLiHaoCommented:
Show the code on how you integrate with the CMS.

Also show the errors.
0
ShopiesAuthor Commented:
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

flash-error.jpg
0
TanLiHaoCommented:
No I don't need the PHP code, I just want to see how you used the component.

The errors are caused because you put the code on a frame instead in a .as file. However, anyway just post how you use the component, not the php code, but the as code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShopiesAuthor Commented:
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;
				
				data.push(temp);
			}
			// Initiate the products!
			initProducts();
		}
		
		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);
				imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progressHandler);
				
				imgLoader.load(imgRequest);
				
				mainHolder.addChild(product);
				product.addChild(imgLoader);
				
			}
			// 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;
			
			loadText(currentIndex);
		}
		
		private function navigationOver(e:MouseEvent):void
		{
			TweenLite.to(e.currentTarget.arrow,0.5,{alpha:0.9,ease:Expo.easeOut});
			TweenLite.to(e.currentTarget.bar,0.5,{alpha:0.4,ease:Expo.easeOut});
		}
		
		private function navigationOut(e:MouseEvent):void
		{
			TweenLite.to(e.currentTarget.arrow,0.5,{alpha:0.2,ease:Expo.easeOut});
			TweenLite.to(e.currentTarget.bar,0.5,{alpha:0,ease:Expo.easeOut});
		}
		
		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);
			}
			else
			{
				// Slide mainHolder to show next product
				newX						= Math.round(currentIndex * (imageSpacing * -1));
				TweenLite.to(mainHolder,slideTweenDuration,{x:newX,ease:Expo.easeOut});
				loadText(currentIndex);
			}
		}
		
		private function moveItemsLeft(e:MouseEvent):void
		{
			currentIndex					-= 1;
			
			if (currentIndex < 0)
			{
				// Beginning of the product line
				currentIndex = 0;
			}
			else
			{
				// Slide mainHolder to show next product
				newX						= Math.round(currentIndex * (imageSpacing * -1));
				TweenLite.to(mainHolder,slideTweenDuration,{x:newX,ease:Expo.easeOut});
				loadText(currentIndex);
			}
		}
		
		private function mouseWheelEvent(e:MouseEvent):void
		{
			// slide the items by the mouse wheel
			if (e.delta > 0)
			{
				moveItemsLeft(null);
			}
			else
			{
				moveItemsRight(null);
			}
		}
		
		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.
			TweenLite.to(e.target.content,1.5,{alpha:1,ease:Expo.easeOut});
		}
		
		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

0
TanLiHaoCommented:
Can you link me to your site? I would like to see the ??? text.
0
ShopiesAuthor Commented:
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?
0
TanLiHaoCommented:
I need your .xml file.
0
ShopiesAuthor Commented:
Here it is. Please change the file extension into .xml
products.txt
0
TanLiHaoCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.