我正在使用flash中的一个小博客应用程序,似乎无法加载嵌入了html的任何变量。有没有解决的办法? flash代码:
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是:
<?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
?>
我不能成为历史上第一个希望在我传递的变量中利用一些html的人,我听说过AMFPHP,但我希望有一个更简单的解决方案,比如:
flash_encode($myVar);
(类似于json_encode);
感谢您的投入。 -J
答案 0 :(得分:2)
您可以在PHP脚本中尝试urlencode vars。 然后,在内部闪存中,您可以使用unescape(或decodeURI?)
使用AMFPHP,您可以向闪存发送类型持久对象,而不仅仅是字符串。
此外,您可以使用JSON,有as3CoreLib等库可以为flahs提供JSON解码。