In ActionScript 3 is there a way (a hack - maybe through square brackets, maybe through cloning an Object, maybe through prototype, maybe through namespaces, ...) to change a private or protected member of a class?
For example if I have an IconToast
class delivered by a someLibrary.swc and I know it has a
protected var windowOptions:WindowOptions;
Can I change it somehow? I've tried many things, for example:
var errorToast:IconToast = new IconToast();
errorToast.addButton("Dismiss");
errorToast.message = "Error when connecting";
errorToast['windowOptions'].timeout = 10 * 1000;
errorToast.show();
(gives me runtime error ReferenceError: Error #1069: Property windowOptions not found on IconToast and there is no default value).
Do this by extending the base class and giving public access to the private/protected method/property etc.
public class MyIconToast extends IconToast
{
public function getWindowOptions():WindowOptions
{
return windowOptions;//here you can access protected (not private though:);
}
}
for private it may not be possible but similar to above solution to some extent it can be done
Best regards