When you add an object to a boolean, you get trueif the object is not nulland falseotherwise, I like to change this behavior for some objects. I want some objects to return false, even if they don’tnull
I know that in ActionScript 3.0 we can change some default behavior for an object using Proxy. Can we do the same for Boolean(object)or object as Boolean? And how can this be done?
I want to ask about this after the following thought:
I have this code:
if (someObject)
someObject.DoSomething();
This means that it DoSomethingis called only if someObjectnot null, but this only happens because it is a "real" code:
if (Boolean(someObject) == true)
someObject.DoSomething();
And it works because any object is automatically written to Boolean, and the result true, but if the link points to null, the result is equal false.
I want to know if I can change this behavior without adding a new type function isTrue(someObject)or something like that.
Thanks in advance and sorry for the bad english.
source
share