PDA

View Full Version : Problem with Adobe AIR App and assql


jcperuffo
03-10-2010, 03:59 AM
Hello!

I'm trying the assql lib with Adobe AIR and I'm getting confuse with the following. I have a class, called Dao.as, and this class is imported in my main application, wich is all written in Actionscript (so, I don't have mxml components like <mb:Button... in the main file, because these components are written in Actionscript).

In the Dao.as, I have the method bellow (and others too):


public function executaQuery():void {
st = connection.createStatement();
token = st.executeQuery("INSERT INTO ...");
token.addEventListener(MySqlErrorEvent.SQL_ERROR, onSqlError);
token.addEventListener(MySqlEvent.RESPONSE, onSqlResponse);
}

In my main app, after I do this:
var dao:Dao = new Dao();
dao.executaQuery();

The code is correctly executed, because I check the MySQl and the data I provided is there. But if I try to do this on the RESPONSE method event:

private function onSqlResponse(e:MySqlEvent):void {
status = 1;
}

and in the main app I write:
Alert.show("" + dao.getStatus());

I get the number 0 instead of 1.

Does anyone knows why I'm getting the wrong number? The method getStatus() is declared correctly:

public function getStatus():int {
return status;
}

I'm sure that the RESPONSE method is executed, because the INSERT don't fail (I can see the data that I have entered in the mysql). So, if the INSERT is ok, the status variable should have their value changed, because the method of RESPONSE is called. But after I call the getStatus() method in the main app file, I get 0, and not 1 in the Alert.show().

I have tried everything that I know (and it's not much). The question seems to be a Actionscript problem, but I don't know it really. Please, any help will help me a lot!

Thanks!

Regards,

Juliano