PDA

View Full Version : [AS2] Ampersands, Datagrids, TextInput Components


rrrfusco
05-28-2010, 07:23 AM
Hi there,

I'm retrieving this string from an XML file:

'name1 & name2'

The string is then put into a Datagrid object.

When the datagrid is clicked, the string is passed to a textInput component.

I believe the string displays like so in the component:

name1 & name2

Can anyone advise me on how to encode the ampersand correctly
so that both the datagrid and the textInput displays
name1 & name2

I'm not sure if there is a way in flash to do this, or probably PHP I would assume a str_replace?

rrrfusco
05-29-2010, 03:09 AM
The string seems to have been entered incorrectly in the XML file.

XML string: 'name1 & name2'

Should be written: 'name1 & name2'

To correct it, use:
<?php
$name = str_replace("&amp;amp;", "&amp;", $member->screenname);
?>

This will display the literal '&' in the datagrid.

Onchanges on the grid to the textinput will require an actionscript function for string replace.


Try something like this: @ http://www.liamr.com/blog/?p=77
//String Replace Function

function stringReplace(block:String, find:String, replace:String):String
{
return block.split(find).join(replace);
}


Try: &...

myString = "name1 &amp; name2";
output = stringReplace(myString, "&amp;", "&");
trace("NewString = " + output);