开发者

simple javascript to replace 1 movie with another

I'm aware this is probably a very simple problem with a 1-line-of-code answer but I'v开发者_运维问答e been on it a while now and it's still eluding me. We have a site that comprises mainly of an embeded flash object containing navigation controls. All I want is to insert a small .swf movie that will play like an intro scene to the website before the main .swf loads for the site itself. All this means is I want to call up 1 flash object, play it through and then replace it with another once finished. This seems to be a relatively simple desire but after a couple of hours worth of forum-trawling I'm still denied a simple solution. Anyone know any better?


The simpler solution is for all of this to be handled within Flash. That would give you a finer overall control.

If you handled this both with Javascript & Flash, a likely problem will be to have to wait for a movie to be loaded before it starts playing.

You could for instance call a Javascript function from the first movie when it completes playing, but you won't be able to avoid the delay between the two movie whilst the second movie loads.

If for some reasons, you don't have access to the code in any of these movies, create a third movie that will act as a container for both swfs where you'll be able to monitor loading progress and react accordingly.


As far as I know (will be glad if someone will correct me) you can't really know when Flash object has finished loading - for the JavaScript code it's pretty much "black box".

So, your best alternative is hide the "intro" after specific amount of time, for example five seconds:

window.setTimeout("document.getElementById('intro').style.display = 'none';", 5000);

This will hide element with the ID "intro" after five seconds.


There are a couple of solutions.

  • You can embed the intro and the navigation in one movie clip and just show the navigation after the intro movie has played.
  • You can also use ExternalInterface in flash in the intro movie. ExternalInterface allows Flash to call JavaScript functions and vice versa. So you basiclly write a small function in JS that changes the clips and call it via ExternalInterface at the end of the intro.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜