sushihangover / as3-commons

Automatically exported from code.google.com/p/as3-commons
1 stars 0 forks source link

Does this work on built-in classes? #53

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

I wanted to check two things with the as3commons proxy API

1. Does it work on built-in classes and methods?
2. When you intercept a function, does it block? We want to make sure the 
DisplayList isn't modified because our interceptor will be doing calculations 
based on its current state. If ADDED/REMOVED events fire while the intercepted 
method is executing, it will be in an incorrect state.

Thanks a lot!

Original issue reported on code.google.com by mistkni...@gmail.com on 26 May 2011 at 3:49

GoogleCodeExporter commented 8 years ago
Hi there,

sorry for replying a million years too late, this question completely missed me.
But to answer you, yes, the interceptor can block. Its up to the implementation 
to decide whether or when the original method will be called.

cheers,

Roland

Original comment by ihatelivelyids on 10 Aug 2011 at 7:14

GoogleCodeExporter commented 8 years ago
Thanks for the somewhat late answer :) We've already solved the problem with 
the dreaded interFrame event. Just a word of caution, I'm not a Flash developer 
so excuse any incorrect info I assume below.

I want to shed some light on the problem and make sure you're in the same boat. 
We're the authors of the FlashFirebug extension 
(https://addons.mozilla.org/en-US/firefox/addon/161670/), in essence, we 
display the Flash DisplayTree to the user and allow him to manipulate it. When 
a node is removed in the DisplayTree, an event is fired and we communicate this 
to the FireFox extension to update its Display.

A number of methods such as switchNodes and updateChildIndex methods do not 
fire any events. We were looking at the proxy as a possible solution to detect 
the invocation of these non-event-firing methods and to avoid the performance 
costly interframe event to detect this. We were stuck with the issue of 
concurrency, should we be worried that a proxy on these method invocations may 
see the DisplayTree in one state at the beginning of the call and in another 
state at the end of the proxy call? Does the proxy method block the Flash 
player until it completes?

Thanks!

Original comment by mistkni...@gmail.com on 10 Aug 2011 at 9:57

GoogleCodeExporter commented 8 years ago
Hey there,

I'm afraid proxies aren't going to help you out, a dynamic proxy is basically a 
dynamically created subclass that overrides all methods and accessors and 
injects interceptor calls into them. If you want to inject custom code into 
exisiting classes you'd have to perform bytecode weaving, but even that won't 
help you out since DisplayObject is a native flashplayer class, so there's no 
way to manipulate those classes.

I'm sorry...

cheers,

Roland

Original comment by ihatelivelyids on 10 Aug 2011 at 10:23

GoogleCodeExporter commented 8 years ago
Not a problem. At least now we know that the interframe event was in fact the 
only practical way to go about this. We've also made sure to implement it in 
the most efficient way possible.

Thanks for the help :)

Ashraf

Original comment by mistkni...@gmail.com on 11 Aug 2011 at 12:41