 	import flash.utils.ByteArray;
 	import flash.utils.Timer;
 	import sfxworks.services.DatabaseService;
+	import sfxworks.services.events.DatabaseServiceEvent;
 		
 	import sfxworks.NetworkActionEvent;
 	import sfxworks.NetworkEvent;

	import com.maclema.mysql.MySqlToken;
	import com.maclema.mysql.ResultSet;
	import com.maclema.mysql.Statement;
	import flash.desktop.NativeApplication;
	import flash.errors.IOError;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IOErrorEvent;

		public function nameChange(name:String):void
		{
			nameChangeRequest = name;
			var st:SQLStatement = new SQLStatement();
			st.text = "UPDATE users "
				+ "SET name='"+name+"' "
				+ "WHERE publickey=@publickey;";
			st.parameters["@publickey"] = _publicKey;
			
			trace("COMMUNICATIONS: Name change triggered.");
			var result = _databaseService.writeToDB(PUBLIC_KEY_DATABASE, st);
			
			
			if (result is SQLResult)
			{
				trace("COMMUNICATIONS: Name change response success..");
				_name = nameChangeRequest;
				dispatchEvent(new NetworkActionEvent(NetworkActionEvent.SUCCESS, result));
			}
			else if (result is SQLError)
			{
				trace("COMMUNICATIONS: Name change response error:" + result);
				dispatchEvent(new NetworkActionEvent(NetworkActionEvent.ERROR, result));
			}
		}
		
		
