Link to home
Start Free TrialLog in
Avatar of tomdenton
tomdenton

asked on

unescape

Hi, in Flash I am using google translate to take some text, translate it and then put it back in a text box in a chosen language. I have a list of languages to choose etc and it works fine except i end up with things like u0026quot (in the trace) being returned and then using unescape() seems to help but results in uuot still being displayed. The key part of the code is at the bottom of the following.

Any suggestions welcome.
Tom
on (release) {

	var lorem_lv:LoadVars = new LoadVars();
	txtLang.text = "Current language code is: " + lstLang.getSelectedItem().data;
	strLang = lstLang.getSelectedItem().data;
	btnReset._visible = true
	
	if (strLang == null) {
		strLang = "en";
		txtLang.text = lstLang.getSelectedItem().data;
	}

	lorem_lv.onData = function(src:String):Void  {
		clip(src);
		trace(src);
	}

	strSource = escape(txtContent.text);
	//strSource = txtContent.text;
	lorem_lv.load("http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" + strSource + "&langpair=en%7C" + strLang);

	function clip(str:String):Void {
		find_me = "translatedText";
		trace("Found "+str.indexOf(find_me));
		str = str.substr(str.indexOf(find_me)+17, str.length);
		str = str.substr(0, str.indexOf("},")-1);
		txtContent.htmlText = unescape(str);
	}

}

Open in new window

Avatar of dgofman
dgofman
Flag of United States of America image

Can you use AS3?
Avatar of tomdenton
tomdenton

ASKER

If I have to yes, but is it possible in 1 or 2 do you think?
Yes it's possible the reason why I like AS3 I will use a JSON class. But it's fine I can use as2 as well.
ASKER CERTIFIED SOLUTION
Avatar of ute_arbeit
ute_arbeit
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great, thanks