我有評論框項目。基於As3 + PHP的項目。並有#2007 Error.Try修復,但不能做任何事情。如果可以幫助它將是非常有用的。錯誤部分是這樣的:as3 TypeError#2007參數文本必須爲非空不能修復
TypeError:Error#2007:Parameter text must be非空。 在的flash.text ::文本字段/設置文本() 在comment2_fla :: mc_1 /在completeHandler() 在flash.events::EventDispatcher/dispatchEventFunction() 在flash.events::EventDispatcher/dispatchEvent() 在閃光達網絡::的URLLoader /的onComplete()
var variables_re:URLVariables = new URLVariables();
var varSend_re:URLRequest = new URLRequest("guestbookParse.php");
varSend_re.method = URLRequestMethod.POST;
varSend_re.data = variables_re;
var varLoader_re:URLLoader = new URLLoader;
varLoader_re.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader_re.addEventListener(Event.COMPLETE,completeHandler_re);
function completeHandler_re(event:Event):void{
if(event.target.data.returnBody==""){
gbOutput_txt.text = "no data";
} else {
gbOutput_txt.condenseWhite = true;
gbOutput_txt.htmlText = "" + event.target.data.returnBody;
}
}
variables_re.comType = "requestEntries";
varLoader_re.load(varSend_re);
的代碼第二部分:
msg_txt.restrict = "ığüşöç A-Za-z 0-9";
name_txt.restrict = "ığüşöç A-Za-z 0-9";
var errorsFormat:TextFormat = new TextFormat();
errorsFormat.color = 0XFF0000;
processing_mc.visible = false;
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("guestbookParse.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE,completeHandler);
function completeHandler(event:Event):void{
processing_mc.visible = false;
name_txt.text = "";
msg_txt.text = "";
status_txt.text = event.target.data.return_msg;
gbOutput_txt.condenseWhite = true;
gbOutput_txt.htmlText=""+event.target.data.returnBody;
}
submit_btn.addEventListener(MouseEvent.CLICK,ValidateAndSend);
function ValidateAndSend(event:MouseEvent):void{
if(!name_txt.length){
status_txt.text = "İsminizi Girin";
status_txt.setTextFormat(errorsFormat);
} else if (!msg_txt.length){
status_txt.text = "Yorum Girin";
status_txt.setTextFormat(errorsFormat);
}else{
processing_mc.visible = true;
variables.comType = "parseComment";
variables.userName = name_txt.text;
variables.userMsg = msg_txt.text;
varLoader.load(varSend);
status_txt.text = "Yorumunuz Eklendi...";
}
}
和PHP部分:
<?php
mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db("yorum") or die (mysql_error());
if ($_POST['comType'] == "parseComment") {
$name = $_POST['userName'];
$location = $_POST['userLocation'];
$comment = $_POST['userMsg'];
$sql = mysql_query("INSERT INTO guestbook (name, post_date, comment, location)
VALUES('$name', now(),'$comment','$location')")
or die (mysql_error());
$body = "";
$sql = mysql_query("SELECT * FROM guestbook ORDER BY post_date DESC");
while($row = mysql_fetch_array($sql)) {
$id = $row["id"];
$name = $row["name"];
$post_date = $row["post_date"];
$comment = $row["comment"];
$location = $row["location"];
$comment = stripslashes($comment);
$name = eregi_replace("'", "'", $name);
$location = eregi_replace("'", "'", $location);
$comment = eregi_replace("'", "'", $comment);
$post_date = strftime("%b %d, %y", strtotime($post_date));
$body .= '<u><b><font color="#790000">' . $name . '</font> | <font color="#9B9B9B">' . $location . '</font> | <font color="#9B9B9B">' . $post_date . '</font></b></u>
<br />
'.$comment.'
<br />
<br />
';
}
mysql_free_result($sql);
mysql_close();
echo "return_msg=Entry has been added successfully $name, thanks!&returnBody=$body";
exit();
}
if ($_POST['comType'] == "requestEntries") {
$body = "";
$sql = mysql_query("SELECT * FROM guestbook ORDER BY post_date DESC");
while($row = mysql_fetch_array($sql)) {
$id = $row["id"];
$name = $row["name"];
$post_date = $row["post_date"];
$comment = $row["comment"];
$location = $row["location"];
$comment = stripslashes($comment);
$post_date = strftime("%b %d, %y", strtotime($post_date));
$body .= '<u><b><font color="#790000">' . $name . '</font> | <font color="#9B9B9B">' . $location . '</font> | <font color="#9B9B9B">' . $post_date . '</font></b></u>
<br />
'.$comment.'
<br />
<br />
';
}
mysql_free_result($sql);
mysql_close();
echo "returnBody=$body";
exit();
}
?>
我添加了一些可能的修復,你只需要使用默認值,如果消息是nll或undefined – simion314