FORUMS: list search recent posts

Load/ unload external SWF

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Carlos Angeli
Load/ unload external SWF
on Aug 30, 2010 at 5:21:53 pm

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:

loadMovieNum("movie01.swf", 1);

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

Return to posts index

demetri tashie
Re: Load/ unload external SWF
on Aug 31, 2010 at 3:01:32 am

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 :



flvPlayer.addEventListener(VideoEvent.COMPLETE, changeVideo);
function changeVideo(evt:VideoEvent):void{
else{ flvPlayer.source="vid1.flv";}

the function just uses a simple "if" logic statement to change the videos

hope that helps

Return to posts index

Carlos Angeli
Re: Load/ unload external SWF
on Aug 31, 2010 at 4:15:23 pm

Hi demetri,

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?

Return to posts index

demetri tashie
Re: Load/ unload external SWF
on Aug 31, 2010 at 6:01:03 pm

looking at your example, there are 2 items that could be called a 'banner'.
the one on top of the page are jpeg images rotating via javascript ( JQuery ).

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:


var is1playing:Boolean=true;

flvPlayer1.addEventListener(VideoEvent.COMPLETE, changeVideo);
flvPlayer2.addEventListener(VideoEvent.COMPLETE, changeVideo);

function changeVideo(evt:VideoEvent):void{
{;flvPlayer2.visible=true; flvPlayer1.visible=false; flvPlayer1.stop(); is1playing=false;}
{;flvPlayer1.visible=true; flvPlayer2.visible=false; flvPlayer2.stop(); is1playing=true}

hope that makes sense and helps. i could post examples if that would help.

Return to posts index

Carlos Angeli
Re: Load/ unload external SWF
on Aug 31, 2010 at 6:20:59 pm

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.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved