This request deletes a user variable. A user variable can also be deleted by the server. A client can only create, modify, or delete a user variable that it owns (so not one for another user).
This shows how to delete a user variable and capture the resulting update event.
private var _es:ElectroServer;
private function initialize():void {
_es.engine.addEventListener(MessageType.UserVariableUpdateEvent.name, onUserVariableUpdateEvent);
testDeleteUserVariable();
}
private function testDeleteUserVariable():void {
//create the request and populate it with info
var duvr:DeleteUserVariableRequest = new DeleteUserVariableRequest();
duvr.name = "myDescription";
//send to the server
_es.engine.send(duvr);
}
private function onUserVariableUpdateEvent(e:UserVariableUpdateEvent):void {
var userVar:UserVariable;
switch (e.updateAction) {
case UserVariableUpdateAction.VariableCreated:
//the user variable is managed, so grab it
userVar = _es.managerHelper.userManager.me.userVariableByName(e.variable.name);
trace("User variable created. Name: " + userVar.name + ", value: " + userVar.value.toString());
break;
case UserVariableUpdateAction.VariableDeleted:
//the user variable has already been deleted, so to see its name inspect the event object
trace("User variable deleted. Name: " + e.variable.name);
break;
case UserVariableUpdateAction.VariableUpdated:
//the user variable is managed, so grab it
userVar = _es.managerHelper.userManager.me.userVariableByName(e.variable.name);
trace("User variable updated. Name: " + userVar.name + ", value: " + userVar.value.toString());
break;
}
}