Workaround for the Video.clear() Bug
While building video templates recently, I had my first run-in with ActionScript 3.o’s infamous Video.clear() bug. The bug is that calling Video.clear() only removes one pixel of a video, rather than the whole video.
The common workaround for the bug is to simply remove the Video component from the stage when the movie is complete. This solution is not robust enough for my purposes because I continue to use use the Video instance to play other movies. Also, the video templates will be used by a client to develop screens for courses, and the client might change properties of the component (name, placement, etc.) so a function that always creates a component with predetermined values is not an option either.
Below I have pasted the function I use in a custom VideoHandler class to create a duplicate Video component, clear the original Video component, and place the new on the stage.
private function fClearVideo():void
{
// Stops playing video and deletes the local copy of the video, though it may still exist in cache
_ns.close();
// There is a bug with _video.clear where it only clears 1 pixel of the video
// This bug was noted in 2008, exists in Flash Player 9 and 10, and unfortunately has not been fixed
// Duplicate the Video component
var videoDouble:Video = new Video;
videoDouble.x = _video.x;
videoDouble.y = _video.y;
videoDouble.width = _video.width;
videoDouble.height = _video.height;
videoDouble.name = _video.name;
// Remove Video instance from the stage and add the duplicate instance.
this.removeChild(_video);
_video = this.addChild(videoDouble);
}
