Load/ unload external SWF
Hi, I´m new to Action script, so I´m having a hard time trying to achieve this.
A SWF file, acts as a container. It has one frame with the following action script:
The loaded swf (movie01.swf) keeps playing in a loop, and that´s ok.
This worked fine so far, but now, I´ve been asked to play another movie after the first one. So I´m trying to somehow, unload the first movie after it has played completely, and then load the second one, and make this sequence a loop. All this should happen without using buttons.
Is this possible? Can anyone give some insight on this? Thanks
it can be done fairly easily if you are using a FLVPlayback Component.
you then use the Video Event COMPLETE to do a function when the video player recognized that the flv has completed playing.
if the flv player has an instance name of 'flvPlayer' and you use 'vid1.flv' and vid2.flv' , you can use this code to make it work :
the function just uses a simple "if" logic statement to change the videos
hope that helps
this project is intended for a banner. The container should be able to display one sequence without player controls and then load the next one.
This is an example of what I´m talking about:
After a banner like that ends, another one should be loaded right away and then go back to play the first one. I´m not putting everything in a single file to keep the size smaller.
Do you think it could still work with you method?
looking at your example, there are 2 items that could be called a 'banner'.
the other one, in the Telefonia section is a swf. that 'banner' is just a swf, so the answer is yes, of course it can still be done, with the same code.
now, you have to think abou this: do you want, or need, these to be seemless transition from one video to the other? the code i have written so far will have that slight pause and gap from the ending of one video the the loading and beginning of the other video. with one video player, that is almost unavoidable. there are several different 'tricks' you can do to make it appear otherwise.
that will depend on what the two videos are. lets say they both have the same background static image, and each one just has different copy and or effectts on top of that background. then you could export a still of the backgound, and have that behind the video player, so as the video player disappears and re-appears with the next one, you are seeing the still. this could make it appear seemless
or if both videos have the same fade in/fade out , then an exported still of either first (or last ) frame serves the same purpose
another way is to use 2 video players perfectly aligned. the logic is that they are both loaded.
they both have the same event listener as the previous example.
the first one is visible, and plays. the second one is stopped, and not visible.
when the first one ends, the second becomes visible and plays, while the first one stops and becomes invisible, and vise-versa. you'll see that i used a simple Boolean variable to keep track of which player is playing.
here is some simple, complete code that takes care of all that. as with most coding jobs, there are multiple ways to even approach obtaining a result. this is just one of them:
hope that makes sense and helps. i could post examples if that would help.
Thank you for such a complete answer demetri. I´ll see if I can make it work with the script you just gave me and if I can´t, those examples would be very handy.