2013-05-25 110 views
1

在我的Flash文件,我有以下ActionScript代码:未定义指数

gameEnd.submitBtn.removeEventListener(MouseEvent.MOUSE_DOWN, submitScore); 

submitScore功能如下:

public function submitScore(e:MouseEvent):void 
    { 
     this.addChild(scoreAdded); 
     scoreAdded.x = 165; 
     scoreAdded.y = 85; 

     var url:URLRequest = new URLRequest("./submitscore.php"); 
     var thevariables:URLVariables = new URLVariables(); 
     url.method = "GET"; 
     thevariables.score = scoreText.text; 
     url.data = thevariables; 
     navigateToURL(url,"_self"); 
    } 

在我submitscore.php文件我有:

<?php 

$scorefromflash = $_GET['score']; 
echo ("Score: ".$scorefromflash); 

?> 

但是,这会导致错误Notice: Undefined index: score in submitscore.php。任何人都知道为什么这不起作用?我用完全相同的方式完成了名称和分数,但是使用了不同的变量名称,分数从不起作用。

我真的很感谢任何帮助,因为我今天真的需要解决这个问题。

+0

凡在submitscore功能的 '得分' 变量?如果没有定义,那么这就是为什么你有一个未定义的索引。 – H2ONOCK

+0

意外地将错误的代码行复制到问题中。更新它的实际内容。 – Liam

+0

[PHP:“Notice:Undefined variable”和“Notice:Undefined index”]的可能重复(http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – Jocelyn

回答

0

你忘了添加scorethevariables

var thevariables:URLVariables = new URLVariables(); 
thevariables.score = submitScore; 

,然后添加到thewm要求:

url.data = thevariables; 
+0

糟糕,粘贴了错误的代码行。 – Liam

+0

真的很困惑,为什么当我想输出'nameText.text'而不是scoreText – Liam