我试图为我的比赛做出高分。但是当我试图在sqlite上保存表数据库的高分时,我有一些错误说 TypeError:错误#1009:无法访问空对象引用的属性或方法。 在DDRnew_fla :: MainTimeline / ext()[DDRnew_fla.MainTimeline :: frame26:64] 我的动作就像这样
import flash.filesystem.File;
import flash.data.SQLStatement;
import flash.data.SQLConnection;
import flash.events.SQLEvent;
import flash.events.SQLErrorEvent;
import flash.data.SQLResult;
import flash.events.MouseEvent;
import flash.display.MovieClip;
var fileDB:File;
var koneksi:SQLConnection;
var sqlStatement:SQLStatement;
perfectcount.text = "" + int(perfect);
greatcount.text = "" + int(great);
goodcount.text = "" + int(good);
boocount.text = "" + int(boo);
misscount.text = "" + int(miss);
scorecount.text = "" + int(score);
addEventListener(Event.ENTER_FRAME, ranking);
exit.addEventListener(MouseEvent.CLICK, ext);
init();
function init()
{
koneksi = new SQLConnection();
koneksi.addEventListener(SQLEvent.OPEN, koneksiHandler);
koneksi.addEventListener(SQLErrorEvent.ERROR, errorHandler);
fileDB = new File(File.applicationDirectory.nativePath);
fileDB = fileDB.resolvePath("DDR.db");
koneksi.open(fileDB);
}
function koneksiHandler(e:SQLEvent)
{
sqlStatement = new SQLStatement();
sqlStatement.sqlConnection = koneksi;
sqlStatement.addEventListener(SQLErrorEvent.ERROR, errorHandler);
}
function ranking(event:Event):void
{
if (score>=846000)
{
rank.text = "A";
this.removeEventListener(Event.ENTER_FRAME, ranking);
}
else if (score>=658000)
{
rank.text = "B";
this.removeEventListener(Event.ENTER_FRAME, ranking);
}
else if (score>=470000)
{
rank.text = "C";
this.removeEventListener(Event.ENTER_FRAME, ranking);
}
else if (score>=282000)
{
rank.text = "D";
this.removeEventListener(Event.ENTER_FRAME, ranking);
}
else
{
rank.text = "E";
this.removeEventListener(Event.ENTER_FRAME, ranking);
}
}
function ext(e:MouseEvent):void
{
gotoAndStop("main menu");
var scoretxt:String ="" + int(score);
var ranktxt:String = rank.text;
var queryString:String;
queryString = "INSERT INTO easy1 (score, Rank) VALUES ('" + scoretxt + "', '" + ranktxt + "')";
var sqlQuery:String = queryString;
sqlStatement.addEventListener(SQLEvent.RESULT, querySukses);
sqlStatement.text = sqlQuery;
sqlStatement.execute();
}
function querySukses(e:SQLEvent)
{
sqlStatement.removeEventListener(SQLEvent.RESULT, querySukses);
e.target.removeEventListener(MouseEvent.CLICK, ext);
}
function errorHandler(e:*):void
{
trace("Eksekusi statement error.");
}
第64行是var ranktxt:String = rank.text;并且完美,伟大,善良,嘘,小姐可变得分。
之前我需要一个解决方案