views:

170

answers:

4

Is there a way in AS3 to access the last render of the stage? Is that render result cached somewhere accessible? I specifically cannot re-render the stage myself to a Bitmap because that would be far too expensive, which is why I'm trying to use the last render.

I need this because I'm trying to do some heat-distortion effects within some specific bounds of the screen, and a standard way to do that in 2D is by using a displacement map to jitter the pristine image. Of course, I'm open to other ideas to do heat distortion in Flash.

+1  A: 

I'm 99.9% sure you can't. I've never come across any mention of that before. Would be a great feature though. Sorry, I know that's not particularly helpful.

Tyler Egeto
+2  A: 

I am pretty sure we do not have access to this (although I don't really see why). I know that flash only redraws the changes of the stage from frame to frame. You can see this by right clicking on the Flash Debug Player and selecting "Show Redraw Regions".

You could try looking at what people are doing with the Convolution Filter and the Displacement Map Filter. Here are some examples:

There examples seem to work fine, with good speeds, although they have quite small stage sizes.

TandemAdam
+1  A: 

You cannot acces the raster, but there's a workaround.

Instead of having your application Sprite (or MovieClip) sit on the stage, draw your application sprite onto a bitmap and place that on the stage. This way you render only once, but can access the bitmap from the last render.

The downside is that that Flash renders all of your application sprite each frame (not just the dirty rectangles).

artman
+1, I was afraid of that, unfortunately pre-rendering isn't a good option for my situation (very performance conscious).
Not Sure
+1  A: 

If you don't mind requiring Flash Player 10 you could try a custom Pixel Bender filter attached to the stage or DisplayObject you want to distort.

However if Flash creates a cache bitmap under the covers like it does for the standard filters then performance won't be any better than creating your own bitmap.

darrinm