Flash Based Webcam?

Has anyone had any experience with making a flash based webcam?
I’ve been looking around trying to find some tutorials or any info. Every one I have found so far uses the duplicateMovieClip command to load the image into successive copies of a movieclip. And it works great, if it weren’t for the fact that every time it adds a new movieclip the file keeps getting bigger and bigger. So if you watch the webcam for even a few minutes your machine quickly starts running out of memory. So whats the solution? Well a few have pitched using removeMovieClip command. Only thing is I can’t get it to work! Here is an example of where my code is at now. The .fla itself has three frames of actionscript (the first is pasted below, the second calls the update function, and the third tells it to go back to frame 2 again), and the two movie objects being duplicated. The webcam image and a camera icon I made that you can use to capture the image that’s currently loaded. Any help would be greatly appreciated!


url = "webcam.jpg";
counter = 3;
camcounter = 5;
remcounter = 2;
remcamcounter = 4;
function update() {
    newmovie = "JPG"+counter++;
    remmovie = "JPG"+remcounter++;
    newcammovie = "camera_mc"+camcounter++;
    remcammovie = "camera_mc"+remcamcounter++;
    duplicateMovieClip("JPG", newmovie, counter);
    loadMovie(url, newmovie);
    duplicateMovieClip("camera_mc", newcammovie, camcounter);
    removeMovieClip("JPG"+remcounter++);
    removeMovieClip("camera_mc"+remcamcounter++);
}