Hi,
I’m not sure if this is possible but I’ve been trying to come up with something which uses flash_proxy override getProperty to run some code on a variable call, but to also make use of code-hinting in flash editors (FlashDevelop). So if I’ve got this class
package {
import flash.utils.describeType;
import flash.utils.Proxy;
import flash.utils.flash_proxy;
public dynamic class LangStrings extends Proxy {
public var myVariable:String = "Test <test>";
public var myVariable2:String = "Test 2";
private function findAndReplace($str:String):String {
$str = $str.split("<test>").join("rep");
return $str;
}
private var dataObj:Object = { };
public function LangStrings() {
dataObj = {};
var varList:XMLList = describeType(this)..variable;
var tempList:Array = [];
for(var i:int; i < varList.length(); i++){
tempList.push({name:varList*.@name, content:this[varList*.@name]});
}
tempList.sortOn("name");
for (var j:int = 0; j < tempList.length; j++) {
dataObj[tempList[j].name] = tempList[j].content;
}
}
override flash_proxy function getProperty(name:*):* {
var checkStr:String = dataObj[name];
if (checkStr == null) {
trace("Error - variable not found - id:" + name);
return "!" + name;
}else {
checkStr = findAndReplace(checkStr);
return checkStr;
}
}
}
}
and then I go
var testProxy:LangStrings = new LangStrings();
trace("test var:" + testProxy.myVariable);
This allows code-hinting to work but because it’s a predeclared variable the ‘override flash_proxy function getProperty’ doesn’t trigger and therefore won’t run the findAndReplace function. Any ideas?
Thanks
Richard