一直在缩小这个问题一段时间,感觉我已经接近破解了
我收到错误错误#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
在此先感谢您的帮助,我真的绞尽脑汁。怀疑一个空变量?
答案 0 :(得分:1)
删除前面的?
,它将被解析为密钥的一部分,这将导致密钥以?questions
结束,因此questions
将被取消定义,并尝试调用split
会抛出错误。
?
仅用于在URL中分隔URL和查询字符串。