I'm working in CS4, actionscript 3, player 10, and having an issue with
a BitmapData screen grab I've written. 

The code captures a bitmap of the stage area (not an instance or clip),
adds to a movie clip and then fades that out over a second. When done,
it disposes of the BitmapData using .dispose(), and the containing
clip's visiblitity set to false.

 

The problem is that something is still there, as buttons that were on
the stage are not clickable afterwords - they are blocked.

 

Perhaps I'm missing something obvious, but I can't figure it out. Could
the problem be that I am creating a bitmap of "stage" and not a movie
clip instance? Or a known issue with BitmapData?

 

Here is the code of the full routine. If anyone spots the problem thanks
very much in advance. 

 

//declare all variables and instances outside of functions:

var timeline;

var tween_OS:Tween;

var bitmapData_OS:BitmapData;

var rect:Rectangle;

var oldscreen:MovieClip;

var fadeoutclip:MovieClip;

var bmp_OS:Bitmap;

var geometry:Array;

var transparent:Boolean;

var backgroundcolor:uint;

var fullXfade:Boolean;

var tr:uint;

 

//the initializing function is called first, giving the target as stage,
the rectangle dimensions etc:

//eg : FrameXFade(stage,[0, 100, 980, 398.2],[0,0],true,0xFFFFFF,false);

function FrameXFade(mc,geom,xy,trans,fillCol,crossfade) {

            timeline=mc;

            geometry=geom;

            transparent = (trans==null) ? true : trans;

            backgroundcolor = (fillCol==null) ? 0xFFFFFF : fillCol;

            fullXfade = (crossfade==null) ? false : crossfade;

            rect=new Rectangle(geom[0],geom[1],geom[2],geom[3]);

            oldscreen = new MovieClip();

            oldscreen.x=xy[0];

            oldscreen.y=xy[1];

            fadeoutclip = timeline.addChild(oldscreen);

}

//then the fade function can be called:

function Xfade() {

            if (bitmapData_OS) {

                        bitmapData_OS.dispose();

            }

            bitmapData_OS=new
BitmapData(geometry[2]+geometry[0],geometry[3]+geometry[1],transparent,b
ackgroundcolor);

            bitmapData_OS.draw(timeline, null,null,null,rect);

            bmp_OS=new Bitmap(bitmapData_OS);

            fadeoutclip.visible=true;

            if (fadeoutclip.numChildren>1) {

                        fadeoutclip.removeChildAt(1);

            }

            fadeoutclip.addChild(bmp_OS);

            tween_OS=new
Tween(fadeoutclip,"alpha",Strong.easeOut,1,0,1,true);

 
tween_OS.addEventListener(TweenEvent.MOTION_FINISH,XfadeOSDone);

}

function XfadeOSDone(e:Event) {

 
tween_OS.removeEventListener(TweenEvent.MOTION_FINISH,XfadeOSDone);

            if (bitmapData_OS) {

                        bitmapData_OS.dispose();

//some additional attempts at clearing it when dispose didn't seem to
work

                        fadeoutclip.removeChild(bmp_OS);

                        System.gc();

            }

            fadeoutclip.visible=false;

}

 

 

Tony Fairfield
Programmer
Lifelearn, Inc.

67 Watson Road S, Unit 5
Guelph, ON  N1L 1E3
www.lifelearn.com <http://www.lifelearn.com> 

T: 519-767-5043
F: 519-767-1101

 

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to