Loading Vars into Flash (AS3) Happy Until HTML Tags Pop Up
I'm working on a little blog app in flash and can't seem to load any variables with html embedded. Is there a way around this? flash code:
var urlLoader:URLLoader = new URLLoader(new URLRequest(path + "index.php"));
urlLoader.addEventListener(Event.COMPLETE, showData);
function showData(e:Event):void
{
var dataObj:URLVariables = new URLVariables( e.target.data );
trace(dataObj.title); // would traces fine
trace(dataObj.content); // throws error
}
index.php is:
开发者_Go百科<?php
$results = "title=this is my title and will print fine";
$results .= "&content=This will cause an error <b>Because of these html tags</b>";
print $results
?>
I can't be the first guy in history looking to take advantage of some html in my passed variables, I've heard of AMFPHP, but am hoping there is a more simple solution, like:
flash_encode($myVar);
(similar to json_encode);
Thanks for the input. -J
You could try urlencode the vars in your PHP script. Then, inside flash you can use unescape ( or also decodeURI?)
With AMFPHP you send type-persistent objects to/from flash, not only string.
Also, you could use JSON, there are libraries such as as3CoreLib that provide JSON decoding to flahs.
精彩评论