actionscript 3 - AS3 - Loading multiple videos into the same container - addChild removeChild -
this function loads specific video movieclip container @ 0.0 using video class.
public var mainvideo:simplevideo; public function loadvideo(videostring:string) :void{ mainvideo = new simplevideo("videos/"+videostring+".flv","",true,video_container.positionmc); video_container.addeventlistener(mouseevent.mouse_down,controlvideoplayer); addchild(mainvideo); trace('adding new video container'); }
i'd preferably check, each time video loaded, see if there video loaded. , if there is, remove it, , add new video.
i've tried using removechild()
in variety of ways, doesn't seem work correctly.
would use removechild(mainvideo)
? video_container.removechild(mainvideo)
? , how able check if there existing mainvideo
?
any appreciated!
-update- if try , use removechild(mainvideo)
error:
typeerror: error #2007: parameter child must non-null.
@ flash.display::displayobjectcontainer/removechild()
@ main/removevideo() @ methodinfo-127()
if add video container movieclip rather onto stage, , container has 1 instance of simplevideo in display list @ time, do:
if( myvideocontainer.numchildren > 0 ) { myvideocontainer.removechild( myvideocontainer.getchildat( 0 ) ); }
a bigger issue though how simplevideo class using cleans up. video classes have cleanup or kill function removes listeners , cleans netstream. think you'd need call removing video instance container.
Comments
Post a Comment