So I have this method (see below) that according to profiler is taking
400 milliseconds each round trip to finish. I was wondering if there
was a way to optimize it?  Maybe I am going about it the wrong way. I
have to draw 100+ of the reflections and it is killing the CPU and
taking forever to finish all the drawing. BTW, the bitmapdata objects,
all 100+, are all different so I can't reuse them.

The other issue is that each time the user visits this section of the
site they will have to wait for this to run 100+ times. I was thinking
about caching the bitmaps on the clients machine via a RSO. I would
just cache them in the flash player, but it takes up to much space so
I need GC to clear them out when they navigate away. Does anyone have
any suggestions on how to cache these bitmaps? 

public function drawMyReflection(arg:*=null):void
                {
                        if (!_bitmap.visible || width <= 0 || height <= 0)
                                return;
                        
                        // Draw reflection      
                        var matrix:Matrix = new Matrix();
                        matrix.scale(scaleX, -scaleY);
                        matrix.translate(0, height);
                        
                        var bitmapData:BitmapData = new BitmapData(width, 
height, true, 0);
                        
                        var oldAlpha:Number = alpha;
                        alpha = 1;
                        bitmapData.draw(this, matrix, transform.colorTransform,
BlendMode.LAYER);
                        alpha = oldAlpha;
                        
                        // Add fade
                        var shape:Shape = new Shape();
                        var gradientMatrix:Matrix = new Matrix();
                        
                        gradientMatrix.createGradientBox(width, height, Math.PI 
/ 2, 0, 0);
                        shape.graphics.beginGradientFill(GradientType.LINEAR, 
[0, 0],
                                [_fadeTo, _fadeFrom], [150, 255], 
gradientMatrix);
                        shape.graphics.drawRect(0, 0, width, height);
                        
                        bitmapData.draw(shape, matrix, null, BlendMode.ALPHA);
                        
                        // Apply Results
                        _bitmap.bitmapData.dispose();
                        _bitmap.bitmapData = bitmapData;
                        
                }

Reply via email to