String Constructor: self-contained re-assignment ??
I'm puzzled by this:
Why can't I re-assign a new value to a String instance using a custom constructor method? It seems that the following code should work, but it fails every time. (MX 2004)...
Code:
function extendString() {
String.prototype.replaceValue = function(newValue:String) {
this = newValue;
};
}
extendString();
var myString = "this is the initial string value";
myString.replaceValue("this is the changed string value");
// myString should now have a different value, but it doesn't!
// the following works, but is NOT self-contained:
// myString = myString.replaceValue("this is the changed string value");
Any ideas? Essentially, I want to be able to alter the instance of String internally just like the behavior of the Array.splice() method.
+Q__