Copy link to clipboard
Copied
I have a layered window system that produces Windows 7 Aero Glass effect in Flash.
It consists of nested display objects, with overlays as so.
Root [
GlassWindowTop [
RenderedEffectBackground
],
BackgroundForGlassWindowTop [
GlassWindowMiddle [
RenderedEffectBackground
],
BackgroundForGlassWindowMiddle [
GlassWindowBottom [
RenderedEffectBackground
],
BackgroundForGlassWindowBottom (e.g. the DesktopBackground)
]
]
]
Windows can be raised and lowered by changing their order in the hierarchy and adding new levels.
Each glass window has a designated background (containing all lower windows) . It draws to an off-screen Bitmap the region of the background that is under the window, and applies a blur filter, tint, and parallax effects to it, and then displays that as it's own background as RenderedEffectBackground.
The problem is that "RenderedEffectBackground" is a static rendering of the window background, so in order to update it in real time, I need to detect when it's background display object (e.g. BackgroudnForGlassWindowTop) or any nested display objects are rendered.
I could simply update all RenderedEffectBackgrounds from the bottom up each frame, but that would be inefficient. Ideally, I could detect when a particular background changes (e.g. when a textfield cursor is flashing, or a MovieClip changes frames), and then only render from that object up. The rendering of course always has to take place from back to front, starting with the lowest window that has changed. If I could detect the redraw regions of the Flash Player (e.g. when a textfield cursor is flashing, or a MovieClip is playing), I could optimize this system even further by checking for layer overlaps and only rendering layers whose windows intersect the redraw regions, but obtaining that level of information would probably not be possible or logical since this this essentially needs to happen during some kind of pre render phase, which Flash may not support. Such a pre-render phase would itself be causing new redraw regions, but as long as it is processed from the bottom up, it could work.
Is there any AS3 function of the flash player that allows my code to obtain information about the display list as far as which display objects are due to be rendered, and then intercept some kind of "onRenderComplete" event for them right before rendering takes place so that I can render the higher display objects.
I originally tried to implement this as a filter, but pixel bender shaders in AS3 don't seem to allow sampling of an underlying object that would allow for blurring (i.e. the shader can access only the current point being rendered, coordinates passed to the sampling methods are ignored (this is documented behavior).
Any ideas?
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now