flash actionscript:
Greetings, You should be able to change you ecomplete function to make this work. Here is my version. Give it a go and let us know if it worked for you: function ecomplete(e:Object):Void { ++videoPlayerIndex; if(videoPlayerIndex >= videoList.length) { vidComp.stop(); // We are at the end of the videoList } else { vidComp.activeVideoPlayerIndex = videoPlayerIndex; vidComp.visibleVideoPlayerIndex = videoPlayerIndex; vidComp.play(); // There are more videos to play } }
I'm using the script below (from theFlash pro 8 training guide) to load two videos (one after another). The way it's written it continuously loops through both videos. Is there a way to play both and stop at the end - ready to replay? var videoLoaderIndex:Number = 0; var videoPlayerIndex:Number = 0; var videoList:Array = new Array( "l_ad2.flv", "l_int.flv"); vidComp.contentPath = videoList; function eready(e:Object):Void { if( videoLoaderIndex < videoList.length ) { videoLoaderIndex++; vidComp.activeVideoPlayerIndex = videoLoaderIndex; vidComp.load( videoList ); } } vidComp.addEventListener("ready", eready); function ecomplete(e:Object):Void { ++videoPlayerIndex; if(videoPlayerIndex >= videoList.length) { videoPlayerIndex = 0; } vidComp.activeVideoPlayerIndex = videoPlayerIndex; vidComp.visibleVideoPlayerIndex = videoPlayerIndex; vidComp.play(); } vidComp.addEventListener("complete", ecomplete );
Try this in the ecomplete event: if(videoPlayerIndex >= videoList.length) { videoPlayerIndex = 0; return; } This should set the index to the first movie and return, avoiding the play call later in the event. greets, blemmo
Thanks, blemmo I'm new to flash and that change is a lot closer than I got. But, although it stops at the end of both videos - when you play it again it only plays the second video and loops through it twice. Any thoughts?
Try to set 'videoLoaderIndex' also to 0: if(videoPlayerIndex >= videoList.length) { videoPlayerIndex = videoLoaderIndex = 0; return; } This is quite complex code for Flash starters... Hope I could help with it. cheers, blemmo
I changed setting the videoPlayerindex = 0 to videoPlayerindex =1 (with the return; you suggested). It plays both videos and stops then plays the second video one time with each replay - this works great for my application since the first vid is an ad they've already been forced to watch once. Thanks for your help!
Don't see what you're looking for? Try a search.
|