我目前正在使用 ActionScript 3 试验 AMFPHP,一切正常,但是当我将数据插入数据库时出现以下错误,但数据将插入我的数据库。
下面是PHP中的代码:
<?php
public function setColor($kleur){
mysql_query("INSERT INTO kleuren (kleuren) VALUES ("'.$kleuren."')");
return $kleur;
?>
现在忽略安全问题我是最新的 SQL 注入,但现在这并不重要。
我的 AS3 代码如下所示:
import fl.controls.Button;
import fl.events.ComponentEvent;
import flash.display.Stage;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.NetConnection;
import flash.net.Responder;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
/**
MidasSerialComm 2.6.1
Attributes
input
a value which receives from serial port.
Methods
serIn()
Returns a String value read from serial port.
serOut(String arg)
Send "arg" to serial port.
No return value.
*/
// The belows are parameters for configuration of module
midas.commport="COM4"; // necessary field
//midas.baudrate="9600";;
//midas.parity="n";
//midas.databit="8";
//midas.stopbit="1";
//midas.eof="ascii 13";
//midas.stx="null";
//midas.etx="null";
//midas.debug=false;
midas.serverip="localhost"; // necessary field
midas.serverport="8864"; // necessary field
midas.visible = false;
//knoppen rood , groen en blauw opzetten
var roodLampje:Sprite = new Sprite();
roodLampje.graphics.beginFill(0xFF0000);
roodLampje.graphics.drawRect(stage.stageWidth / 2 + -150, stage.stageHeight / 2, 60, 40);
roodLampje.buttonMode = true;
addChild(roodLampje);
var groenLampje:Sprite = new Sprite();
groenLampje.graphics.beginFill(0x00FF00);
groenLampje.graphics.drawRect(stage.stageWidth / 2 + -80, stage.stageHeight / 2, 60, 40);
groenLampje.buttonMode = true;
addChild(groenLampje);
var blauwLampje:Sprite = new Sprite();
blauwLampje.graphics.beginFill(0x0000FF);
blauwLampje.graphics.drawRect(stage.stageWidth / 2 + -10, stage.stageHeight / 2, 60, 40);
blauwLampje.buttonMode = true;
addChild(blauwLampje);
var zetLampjeUit:Sprite = new Sprite();
zetLampjeUit.graphics.beginFill(0x000000);
zetLampjeUit.graphics.drawRect(stage.stageWidth / 2 + 60, stage.stageHeight / 2, 60, 40);
zetLampjeUit.buttonMode = true;
addChild(zetLampjeUit);
//kleuren
var rood:String = "Rood";
var groen:String = "Groen";
var blauw:String = "Blauw";
var huidigKleur:String;
var netConnection:NetConnection;
var responder:Responder;
//click events toevoegen aan buttons
roodLampje.addEventListener(MouseEvent.CLICK, onRoodClick);
groenLampje.addEventListener(MouseEvent.CLICK, onGroenClick);
blauwLampje.addEventListener(MouseEvent.CLICK, onBlauwClick);
zetLampjeUit.addEventListener(MouseEvent.CLICK, onUitClick);
//connectie met service
netConnection = new NetConnection();
netConnection.connect("http://navidmirzaie.com/amfphp/gateway.php");
responder = new Responder(onResult, onFault);
var t:TextField;
var textFormat:TextFormat = new TextFormat("Verdana",14,0x000000);
midas.ondata = function(msg){
switch(msg){
case "49":
huidigKleur = rood;
netConnection.call("ArduinoTest.setColor",responder,huidigKleur);
//trace(huidigKleur);
break;
case "50":
huidigKleur = groen;
netConnection.call("ArduinoTest.setColor",responder,huidigKleur);
//trace(huidigKleur);
break;
case "51":
huidigKleur = blauw;
netConnection.call("ArduinoTest.setColor",responder,huidigKleur);
//trace(huidigKleur);
break;
case "48":
break;
}
}
//click handlers, reageer op de gedrukte knop
function onRoodClick(eventObj:MouseEvent):void {
midas.output("1");
//trace("er is op rood geklik");
}
function onGroenClick(eventObj:MouseEvent):void {
midas.output("2");
//trace("er is op groen geklik");
}
function onBlauwClick(eventObj:MouseEvent):void {
midas.output("3");
//trace("er is op blauw geklik");
}
function onUitClick(eventObj:MouseEvent):void {
midas.output("0");
//trace("er is op blauw geklik");
}
//data afhandeling post
function onResult(responds:Object){
var t:Array = new Array();
t = responds.serverInfo.initialData;
//var t:Array = responds.serverInfo.initialData;
trace(t.length);
/*
for(var i:uint = 0; i < t.length; i++){
trace("Aantal "+t[i][0]+" "+t[i][1]);
}
*/
}
function onFault(responds:Object){
for(var i in responds){
trace(responds[i]);
}
}
netConnection.call("ArduinoTest.getCountofTotallColors",responder);
//data ophalen van arduino
我收到此错误:
ReferenceError:错误#1069:
serverInfo
找不到属性String
并且没有默认值。在 test2_fla::MainTimeline/onResult()
我不明白错误的重点,这就是我无法调试代码的原因。