2012-10-24 36 views
0

时已经缩小这个问题一会儿,感觉像我接近咔吧错误1009导入PHP到Flash

我收到错误错误#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(弦乐)必须是包含名称/值对

这是我的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 

由于在URL编码的查询字符串提前寻求你的帮助,真的把我的大脑绞尽脑汁。怀疑一个空的变量?

回答

1

取出前述?,它会被解析为关键,这将导致关键,最终成为?questions的一部分,因此questions将是不确定的,并试图援引split将抛出错误。

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

+0

尝试清除缓存(在Windows上,独立Flash Player使用Internet Explorers缓存)。还要检查你是否收到任何数据,如果是的话,看起来是什么样的:'trace(event.target.data);'。如果您正在接收正确的数据,请指定错误发生的位置! – ndm

+0

对它进行排序,非常感谢,是一个愚蠢的错误。 – Esyem