无法获得swfobj.TotalFrames和swfobj.TCurrentFrame('/')

时间:2013-05-24 21:43:01

标签: javascript swfobject

我试图从我的swf对象获取当前帧或甚至总帧数,但我不断得到未定义。

// swfObject
var flashvars = {};
var params = {};
var params = {};
var attributes = {
  id: 'flashDiv'
};

swfobject.embedSWF("/static/diag/countdown.swf", "flashDiv",
                  "550", "400", "8.0.0", "expressInstall.swf", flashvars,
                  params, attributes);

var swfobj = $('#flashDiv').get(0);
setInterval(function(){console.log("TotalFrames: " + swfobj.TotalFrames)},1000);

在swf完成播放后我会很好地定义。我也拿不到 swfobj.TCurrentFrame('/')也可以。我很感激任何人都可以给予的任何帮助。

1 个答案:

答案 0 :(得分:1)

使用回调函数,就像这样

function callbackfunc(e){
  setInterval(function(){console.log("TotalFrames: " + e.ref.totalFrames)},1000);
}
swfobject.embedSWF("/static/diag/countdown.swf", "flashDiv",
              "550", "400", "8.0.0", "expressInstall.swf", flashvars,
              params, attributes, callbackfunc);