WallArcher
09-27-2006, 11:35 PM
Hi,
Is there any way to change a property / variable key and not touching it's value?
An example of what i'm trying to do:
//Create 2 string variables and an Object.
var key1:String = "k1";
var key2:String = "k2";
var myObject:Object = new Object();
//Create a new property for myObject:
myObject[key1] = "some string";
//The slow way:
delete myObject[key1]; //nolonger needed
myObject[key2] = "some string"; //allocating new memory greatly slows the app
//A fictional method:
myObject.changePropertyName(key1, key2);
trace(myObject[key2]); //should trace "some string"
Now, is it possible to change from key1 to key2 without first having to delete and reallocate memory for key1's original value? Basically treating the property as a pointer. I really need this because it would greatly speed up an app i'm working on.
Thanks.
Is there any way to change a property / variable key and not touching it's value?
An example of what i'm trying to do:
//Create 2 string variables and an Object.
var key1:String = "k1";
var key2:String = "k2";
var myObject:Object = new Object();
//Create a new property for myObject:
myObject[key1] = "some string";
//The slow way:
delete myObject[key1]; //nolonger needed
myObject[key2] = "some string"; //allocating new memory greatly slows the app
//A fictional method:
myObject.changePropertyName(key1, key2);
trace(myObject[key2]); //should trace "some string"
Now, is it possible to change from key1 to key2 without first having to delete and reallocate memory for key1's original value? Basically treating the property as a pointer. I really need this because it would greatly speed up an app i'm working on.
Thanks.