Anyone knows a way of setting a method inside a class to execute right before the class instance deletion?
Tanks for helping!
Anyone knows a way of setting a method inside a class to execute right before the class instance deletion?
Tanks for helping!
I’m grasping at straws here, but do any of these apply;
Event.REMOVED_FROM_STAGE // Obviously not before deletion but chances are you delete your object after you removechild it?
Event.REMOVED // No idea what this actually listens for
Event.CLOSE // Same here 
Yeah, REMOVED_FROM_STAGE could be a way to go, but I’m actually concerned to do that before deletion of any type of AS3 object, not only the DisplayObject ones.
REMOVED listens for the instance time just before the stage removal, and CLOSE listens for socket communications closures.
I was wandering if there’s any type of AS2 ‘__resolve’ method I could put inside my class, but for just-before-deletion cases. This sucks.
Actually, I’m trying to avoid inserting a method suicide()/delete()/cancel() inside a class I’m building right now. I would like to leave it open to developers just ‘delete’ the class instance.
Any additional ideas?
Sorry, not much. I mean the replacement for resolve are proxies. with override function etc…
I’ve tried extending Proxy and overriding the deleteProperty(name*):Boolean, and it does work for inner properties of my object. But my object itself cannot be deleted this way because delete is a statement. So in order to do that I should find ways to make the object container to extend proxy - what is unpractible.
What do you think? Should Adobe implements that kind of feature?
And to make things worse, ‘delete this;’ returns true. But object doesn’t go away, it keeps tracing and acting to external prompts… I can even keep calling its methods. LOL
Well that’s a different story, stuff doesn’t go away after a delete if it has references to it like listeners or whatnot…
quite frankly I don’t see what the difference between an justbeforedelete event and something like calling a public function int he class, waiting for a event (custom event dispatch) and THEN delete it… like a delete proxy in the main class.
Flash definitely doesn’t support finalizers.
Sekasi, I see big difference. In your example we should get an external 3 step code to delete that instance. If we could count on a event like we’re talking about, it should be reduced to 0.
Krilnon, what other languages you know that support finalizers?
Tanks everyone!
[QUOTE=ad.sign;2351283]Sekasi, I see big difference. In your example we should get an external 3 step code to delete that instance. If we could count on a event like we’re talking about, it should be reduced to 0.
Krilnon, what other languages you know that support finalizers?
Tanks everyone![/QUOTE]
But we can’t, it’s simply not a feature of ActionScript, nor have I seen it even talked about for AS4… your real question is how to go about best accomplishing something like what you’ve said, because what you’ve said simply isn’t possible.
Krilnon, what other languages you know that support finalizers?
C#, Python, Java, Ruby.
:: Copyright KIRUPA 2024 //--