visual change notification event?
Anybody that happens to know how to do this would really be helpi开发者_Go百科ng me out.
Maybe its simple, I don't know, but it involves embedded SWF's so I imagine it could entail interacting with event handlers or methods in an embedded SWF.
But anyway, here it is:
I have several embedded SWF's on a canvas (in SWFLoaders) and when one of them changes visually I need to know which one changed.
The 'render' event provides only part of the solution:
If an SWFLoader contains a videodisplay there are continual render events generated in the parent app while that videodisplay is running. If the SWFLoader just contains some static input control otoh, there are no render messages in the parent app until someone interacts with that control and changes it visually, and then there are render events broadcast in the parent app. So, this is clearly part of what my requirements are.
The problem with the render event however, is that it does not tell you which embedded SWF actually changed (in the target or currentTarget.)
But I need to know which one changed.
(Are there seperate render messages being generated within an embedded app (seperate from those in the parent app) for example, that could be detected.)
My solution is as follows:
When a render event occurs, I check if there is a visible swfloader within the browser window, and then I do a BitmapData.draw of its contents to a bitmapdata which is saved. With each new render event, I compare 10% of the pixels of the saved bitmap to the new bitmap and that will tell me whether or not the embedded .swf visual content has actually changed. a 10% sample has proven to be more than sufficient (just iterating through the vectors of the respective bitmaps with the vector index incrementing by 10, instead of 1.)
BitmapData.draw is plenty fast and iterating through 10000 vector elements is like a millisecond.
精彩评论