Problems removing FLV seekBar component from stage in AS2 SWF

940 views Asked by At

I have an AS2 swf that loads FLV videos into a FLVPlayback component and attaches a seekBar component. When the video stops I unload the seek bar from the screen and set the FLVPlayback.seekBar = null. When another video is to be played I set up the seek bar again by attaching the seekBar component to the stage and assigning FLVPlayback.seekBar = newSeekBarInstance.

Here's my code -

(my_video = FLVPlayback component)

var theSeekBar = _root.attachMovie("SeekBar", "vidSeekBar", this.getNextHighestDepth());
_root.my_video.seekBar = theSeekBar;

When video has stopped -

_root.my_video.seekBar = null;
_root.vidSeekBar.handle_mc.unloadMovie();
_root.vidSeekBar.unloadMovie();
_root.vidSeekBar.removeMovieClip();

What Im noticing is that sometimes the seek bar is removed from the screen and sometimes it isnt? I cant seem to notice any pattern here. Has anyone had similar problems? Do I need to force garbage collection?

1

There are 1 answers

0
weltraumpirat On

unloadMovie() only works for clips you have loaded with loadMovie(). It will not have any effect on other stage instances.

So if you have created your instance on the stage using attachMovie(), removeMovieClip() and setting the seekBar variable to null should be enough to have it garbage collected, unless you have any more references to it (perhaps some event listeners?) somewhere else.

I agree with @duncmc though: You should consider just hiding the seekbar instead of creating and removing it over and over again.