当我从DB中删除行时,它会删除行,但是我没有得到事件,它删除了行(我需要在用户删除某些内容后刷新列表)。以下是处理DB的结果的方法:
private final function onReady(e:EventWithMessage):void
{
switch (action)
{
case "get files":
dispatchEvent(new EventWithMessage(EventWithMessage.FILES, {files: null}));
break;
case "save note":
dispatchEvent(new EventWithMessage(EventWithMessage.SAVED, { ID:e.message.ID } ));
break;
case "delete note":
// Saving and getting files above work! And this is not working
dispatchEvent(new EventWithMessage(EventWithMessage.DELETED, { } ));
break;
}
action = null;
}
private final function onData(e:EventWithMessage):void
{
DATA = e.message.data;
switch (action)
{
case "get files":
// some code was here
dispatchEvent(new EventWithMessage(EventWithMessage.FILES, {files: fileArray}));
break;
case "load note":
dispatchEvent(new EventWithMessage(EventWithMessage.FILE, { text:DATA[0].text } ));
break;
case "delete note":
// And even here it isn't working
dispatchEvent(new EventWithMessage(EventWithMessage.DELETED, { } ));
break;
}
action = null;
}
DELETE方法:
public final function deleteNote(ID:int):void
{
SQLiteManager.SQLM.Operations(String("DELETE FROM Notes WHERE id = " + ID));
action = "delete note";
}
SQLiteManager中的方法(我的类):
public final function Operations(command:String, parameters:Array = null)
{
statement = new SQLStatement ();
statement.sqlConnection = connection;
statement.text = command;
if (parameters && parameters.length > 0)
{
for (i = 0; i < parameters.length; i++)
{
statement.parameters[i] = parameters[i];
}
}
statement.execute (-1,responder);
}
响应者有两种方法:
private final function handleSuccess (result:SQLResult):void
{
if (result.data)
{
dispatchEvent(new EventWithMessage(EventWithMessage.SQLDATA, { data:result.data} ));
}
else
{
dispatchEvent(new EventWithMessage(EventWithMessage.READY, { ID:result.lastInsertRowID } ));
}
}
private final function handleError (e:SQLError):void
{
dispatchEvent (new EventWithMessage(EventWithMessage.ERROR,{error:e.message}));
}
有任何错误,或者只是在DELETE之后没有给出任何结果?请帮助。
编辑:我在等待答案 - 我使用计时器(DELETE刷新文件列表后1秒)。也许它是一个很好的替代事件?
EDIT 2 操作变量为空,当涉及到调度事件O_o为什么它为空?我的天啊。
答案 0 :(得分:0)
分辨!!!有一个事件,我做了一些&#34;追踪&#34;并且发现问题是在action变量中,当调度事件时它为null。我删除了行 action = null; ,现在一切正常。万岁:)