【问题标题】:Error 1009 when importing PHP to Flash将 PHP 导入 Flash 时出现错误 1009
【发布时间】:2012-10-24 07:55:37
【问题描述】:

一段时间以来一直在缩小这个问题的范围,感觉我快要解决它了

我收到错误错误 #1009:无法访问空对象引用的属性或方法。

var request:URLRequest = new URLRequest("http://blahblahblah.com/questions.php");
request.method = URLRequestMethod.GET;

var loader2:URLLoader = new URLLoader();
loader2.addEventListener(Event.COMPLETE, completeHandler);
loader2.dataFormat = URLLoaderDataFormat.VARIABLES;
loader2.load(request);

function completeHandler(event:Event) :void{
var questions:String = event.target.data.questions;
var questionsArray:Array=questions.split("/");
questionbox.question.text = questionsArray[numLoops];
trace("QuestionLoaded");
}

有趣的是当我添加一个“。”到 URL 的末尾,所以我有“.PHP”。我得到一个不同的错误代码错误 #2101:传递给 URLVariables.decode() 的字符串必须是包含名称/值对的 URL 编码查询字符串

这是我的 PHP 输出

?questions=The+Sea+Swallow+is+an+alternative+name+for+which+bird%3F%2FIn+which+sport+would+you+see+a+Western+Roll%3F%2FWho+is+better+known+as%0B+Herbert+Khaury%3F%2FDiet+is+the+parliament+of+which+country%3F%2FWhat+is+the+real+first+name+of+Coco+Chanel%3F%2FThe+Aztecs+were+natives+of+which+country%3F%2FWhat+was+invented+by+O.A.+North+in+1869%3F%2FKing+Zog+was+the+ruler+of+which+country%3F&answers=Seagull%2FPenguin%2FTern%2FCormorant&correct=0%2F0%2F1%2F0

在此先感谢您的帮助,我真的为此绞尽脑汁。怀疑是空变量?

【问题讨论】:

    标签: php actionscript-3 flash


    【解决方案1】:

    删除前面的?,它将被解析为key的一部分,这将导致key最终为?questions,因此questions将未定义,尝试调用split将抛出错误。

    ? 仅在 URL 中用于分隔 URL 和查询字符串。

    【讨论】:

    • 尝试清除缓存(在 Windows 上,独立 Flash Player 使用 Internet Explorer 缓存)。还要检查您是否收到任何数据,如果收到,它到底是什么样子:trace(event.target.data);。如果您接收到正确的数据,请指定错误的确切位置!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-05
    • 2013-11-03
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    相关资源
    最近更新 更多