Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

flash: dynamic text

containing & and <xml>

4:47 pm on Nov 4, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 13, 2003
votes: 0

im loading text from a php script into dynamic text boxes in flash mx2004. unofrtunately some of it contains &amps;, some xml tags and other whatnot. when flash encounters one it stops reading that particular text and cuts off in mid sentance.

i dont really want to strip them out server side as the xml tags will be handy.

also, the same text boxes wont show apostrophes ' - just the square box you get when a characters not availabe.

any ideas how to get round this?


6:55 pm on Nov 4, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 3, 2003
votes: 0

G'day, Ben.

Regarding the ampersands, when flash recieves variables from an outside source, eg. a text file or an echo from php, an ampersand is read as an introduction to a new variable name.

For example if the following was in a text file:
&var1=some text&var2=some other text
Flash thinks it is loading 2 separate variables named var1 and var2.

The only way that I know of to get around this is to use String.fromCharCode(38). Where 38 is the unicode value of an ampersand.

myVar = "some text "
myVar += String.fromCharCode(38);
myVar += " some more text"

Result: some text & some more text

I'm not sure of an easy work around for this problem in your case.


Your other question regarding apostrophes could be simpler.
If you are using an embedded font and that font does not have an apostrophe in it is the first thing that comes to mind.

Now if this were a string written within Flash I would suggest using a backward slash [\] in conjunction with the [']. As the [\] is used before various characters for differing effects.

\n is a new line, \" shows quotes, \t tabs the string.

You could try this method in your echo, but no guarantees as I don't have access to a php server handy atm. I only tested this from a text file and the slashes showed up in the text field .

... so after all this I really don't have an easy answer for you.


11:06 am on Nov 5, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 13, 2003
votes: 0

winstun -- thanks again for your help.

im a bit perplexed on the apostrophes - im using verdana and not embedding.