从 AS2 SWF 中的舞台中删除 FLVeekBar 组件时出现问题
我有一个 AS2 swf,它将 FLV 视频加载到 FLVPlayback 组件中并附加一个eekBar 组件。当视频停止时,我从屏幕上卸载搜索栏并设置 FLVPlayback.seekBar = null。当要播放另一个视频时,我通过将seekBar组件附加到舞台并分配FLVPlayback.seekBar = newSeekBarInstance来再次设置搜索栏。
这是我的代码 -
(my_video = FLVPlayback 组件)
var theSeekBar = _root.attachMovie("SeekBar", "vidSeekBar", this.getNextHighestDepth());
_root.my_video.seekBar = theSeekBar;
当视频停止时 -
_root.my_video.seekBar = null;
_root.vidSeekBar.handle_mc.unloadMovie();
_root.vidSeekBar.unloadMovie();
_root.vidSeekBar.removeMovieClip();
我注意到有时搜索栏会从屏幕上删除,有时却不会?我似乎无法注意到这里有任何模式。有人遇到过类似的问题吗?我需要强制垃圾收集吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
unloadMovie()
仅适用于使用loadMovie()
加载的剪辑。它不会对其他阶段实例产生任何影响。因此,如果您使用
attachMovie()
、removeMovieClip()
在舞台上创建了实例,并将eekBar变量设置为 null 应该足以让它被垃圾收集,除非您在其他地方有更多对它的引用(也许是一些事件侦听器?)。不过,我同意@duncmc:您应该考虑隐藏搜索栏,而不是一遍又一遍地创建和删除它。
unloadMovie()
only works for clips you have loaded withloadMovie()
. 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.