flash javascript不起作用(第二次尝试)

时间:2011-05-04 17:25:07

标签: javascript flash

  

可能重复:
  flash javascript don't work

的javascript:

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 TestPlay()
{
    var flashMovie=getFlashMovieObject("myFlashPlayer");
    try
    {
        document.getElementById("TimeDisplay").innerHTML=flashMovie.GetDuration();
    }
    catch(e)
    {
        alert(e.message);
    }
}

HTML:

<object width="150" height="100" id="myFlashPlayer">
<param name="movie" value="Sound.swf"/>
<embed src="Sound.swf" width="150" height="100" name="myFlashPlayer">
</embed>
</object>
<button onclick="TestPlay()" id="TestBtnPlay">Play</button>
<span id="TimeDisplay"></span>

AS 2.0:

_global.track=new Sound();
_global.track.onLoad=finished;
_global.track.loadSound(Path.text,true);
_global.last_position=0;
_global.track.stop();

ExternalInterface.addCallback("GetDuration", GetDuration);
stop();

function finished()
{
_global.track.stop();
}

function GetDuration()
{
    return _global.track.duration;
}

1 个答案:

答案 0 :(得分:0)

试试这个:

function TestPlay()
{
    try
    {
        document.getElementById("TimeDisplay").GetDuration();
    }
    catch(e)
    {
        alert(e.message);
    }
}