View Full Version : Adobe Active Content and Javascript play method not working on Firefox
the.tomato
06-17-2008, 11:25 PM
I've got a page where I want to play a Flash movie when the user clicks on a button. I've got the Adobe Active Content scripts loaded to get around the IE problem.
On the button I've got the following Javascript code: First a function to get the Flash movie object, then one to play the movie.
function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
function PlayFlashMovie()
{
var flashMovie=getFlashMovieObject("advert1");
flashMovie.Play();
}
Problem is this doesn't work in Firefox - it works in all the other browsers. If I remove the Active Content script and just embed the Flash code, it works fine, so it is something to do with Adobe's script.
atomic
06-18-2008, 12:41 AM
The IE problem is no longer an issue...
http://blogs.msdn.com/ie/archive/2007/11/08/ie-automatic-component-activation-changes-to-ie-activex-update.aspx
If you still want to use a workaround, use the swfObject...
http://code.google.com/p/swfobject/
the.tomato
06-23-2008, 02:23 PM
The IE problem wouldn't be an issue if everyone upgraded their browser. Unfortunately that isn't the case yet.
I've also tried the swObject route and that brings up other problems.
I've noticed that the error I'm getting - 'flashMovie.Play is not a function' appears in all the browsers. Clearly it is a function, and on all but Firefox executes that function.
the.tomato
06-23-2008, 11:44 PM
Think I worked it out - its a timing problem. Just needed to do a setTimout on the Play function and it seems to work fine.
DionysusMTL
10-28-2008, 07:09 PM
Could you please explain it and maybe show an example of your code?
I'm having the exact same problem and if you've solved it, would love to know how.
Thanks!
the.tomato
10-29-2008, 03:20 PM
Instead of using flashMovie.Play() I put a delay in. Something like
SetTimeout("flashMovie.Play()")
But looking at the code now, I don't have SetTimout so I can't remember exactly what I changed. It may have been to do with the visibility of the block where the movie was running. The code is below and this is what it does:
1. When the movie finishes it calls advert4_DoFSCommand which hides the block where the movie was.
2. When the image in the page is clicked, it calls PlayFlashMovie which makes the block visible again and plays the movie.
This works on IE6, IE7, FF, Safari
function advert4_DoFSCommand(command,args) {
o=document.getElementById('flashcont');
o.style.display="none";
}
function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
function PlayFlashMovie()
{
var flashMovie=getFlashMovieObject("advert4");
o=document.getElementById('flashcont');
o.style.display="block";
flashMovie.Play()
}
DionysusMTL
10-29-2008, 03:40 PM
I'll give it a shot.. thanks very much!!
DionysusMTL
10-29-2008, 04:02 PM
Hey man.. I'm trying to implement the code.. not sure how to call it?
Just <a href="javascript:PlayFlashMovie();">?
And so the call to advert4_DoFSCommand is in the flash movie?
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.