Groups | Blog | Home
all groups > flash data integration > october 2005 >

flash data integration : [FLAMX+PHP] how to pass special characters as & to flash?


sweetman NO[at]SPAM iol.it
10/7/2005 11:05:20 AM
Hi all,
I have a db containing company names and I need to pass them to flash.

some company names are 'smith & son' so the & is a problem, when
passing strings to flash. in fact i flash I get the company name above
as 'smith', leaving out the '& son' portion.

How can I solve this?

is there a php function that takes care of the conversion from special
characters in strings as &, %, $... to something that do not interfere
with flash reading strings from php?

thansk in advance

SimonTheSwift
10/7/2005 11:33:50 AM
Hi Tony,

data sent to Flash needs to be URL encoded. There is a function in PHP that
does that - urlencode('your string'). Here is a short example:

PHP script: (specialChars.php)
<?php
$string = "special characters: &, $, #, *, %";
echo 'specialChars=' . urlencode($string);
?>

If you see what the echo function sends to Flash, it's:

specialChars=special+characters%3A+%26%2C+%24%2C+%23%2C+%2A%2C+%25

You see how it replaces spaces and special characters with URL equivalents.

ActionScript:
var textFromPHP:LoadVars = new LoadVars();
textFromPHP.load("someURL/specialChars.php");
textFromPHP.onLoad = function() {
trace(this.specialChars);
}

When you run the script inside Flash, you will get the Output window showing
your original string you typed in PHP.


Simon
aisde
4/5/2006 12:00:00 AM
i know it's been a while since this post, but i wanted first to thank you for
posting the most concise and helpful answer to this question that i have found.
AND second to ask, "how do i find a list of the the 2 digit codes to put after
the %?. i have looked several places and found other codes that do not work or
that are not 2 digit, and therefore not "url encoded" i'm guessing. i fixed the
% using %25, but i can't find the digits for the plus sign. thanks.
AddThis Social Bookmark Button