开发者

swfobject & flash -- display loading animation?

I'm using swfobject to dynamically load a flash object into a div, and I'm wondering if there's an easy way to display a loading animation until the flash object is ready for display? In this case, I'm loading an embedded Issuu object, and you can see an example of Issuu loading via swfobject here. Depending on your connection speed, there is typically just a blank white space while the flash object lo开发者_如何转开发ads, and it'd be great to indicate progress with a loading animation if possible. I would imagine jQuery could be of service here...

Thanks for any direction here.


In your embed code, you not only pass an id of the tag you want to be replaced by the swf (idOfTagToReplace), but also an id of the tag replacing it (issuuViewer). Right after your call to swfobject, style the latter tag as you like.

var attributes = {
    id: 'issuuViewer'
};

var params = {
    allowfullscreen: 'true',
    menu: 'false',
    wmode: 'transparent'
};

var flashvars = {
    jsAPIClientDomain: 'www.yourdomain.dk',
    mode: 'mini',
    documentId: '081219132433-764a1eafce5141fda136d10d58bd45f5'
};

swfobject.embedSWF(
    "http://static.issuu.com/webembed/viewers/style1/v2/IssuuReader.swf", 
    "idOfTagToReplace", 
    "420", 
    "264", 
    "9.0.0",
    "swfobject/expressInstall.swf", 
    flashvars, 
    params, 
    attributes
);

var obj = document.getElementById('issuuViewer');
obj.style.backgroundImage = 'url(/img/loading.gif)';
obj.style.backgroundRepeat = 'no-repeat';
obj.style.backgroundPosition = '50% 50%';
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜