I've developed a small control bar for a Flash viewer generated by a third-party software. It has a First, Prev, Next & Last button, and a Zoom command.
While Zoom works fine in all browsers, the navigati开发者_JS百科on buttons seem to fail at Internet Explorer 8.
I use at least two functions. This one locates the Flash object I want to manipulate:
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);
}
}
...and any of these ones handles the frame navigation:
var currentFrame = 0;
function gotoFirst(id)
{
getFlashMovieObject(id + "Blueprints").Rewind();
currentFrame = 0;
$("currentFrame").innerHTML = currentFrame + 1;
$("frameTitle").innerHTML = frameTitles[id][currentFrame];
}
function gotoPrev(id)
{
var movie = getFlashMovieObject(id + "Blueprints");
if (currentFrame > 0)
{
currentFrame--;
}
movie.GotoFrame(currentFrame);
$("currentFrame").innerHTML = currentFrame + 1;
$("frameTitle").innerHTML = frameTitles[id][currentFrame];
}
function gotoNext(id)
{
var movie = getFlashMovieObject(id + "Blueprints");
if (currentFrame < movie.TotalFrames() - 1)
{
currentFrame++;
}
movie.GotoFrame(currentFrame);
$("currentFrame").innerHTML = currentFrame + 1;
$("frameTitle").innerHTML = frameTitles[id][currentFrame];
}
function gotoLast(id)
{
var movie = getFlashMovieObject(id + "Blueprints");
currentFrame = movie.TotalFrames() - 1;
movie.GotoFrame(currentFrame);
$("currentFrame").innerHTML = currentFrame + 1;
$("frameTitle").innerHTML = frameTitles[id][currentFrame];
}
Btw, that $ is MooTools, not jQuery.
Anyway, IE dies on the movie.TotalFrames()
call. What can I do to solve this? Keep in mind I need this to be done via JavaScript, as I cannot edit the SWF.
You can try replacing this code:
if (currentFrame < movie.TotalFrames() - 1)
with this
if (currentFrame < movie.TGetProperty('/', 5) - 1)
It's not as nice, but is another option. TotalFrames()
should work.
精彩评论