2013-05-25 109 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