开发者

Jquery obtain delay until loading

  1. on this code, which loads flash onmouseenter, how can i get some kind of delay, (could use a loading image), untill the browser loads the flash.

I have 10 different sections. If i move the mouse fast between them, flash is loaded several times and it brakes down eventually.

$(".section").mouseenter(functio开发者_运维技巧n() {
    $(this).html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0" width="170" height="125"><param name="movie" value="http://static.awempire.com/flash/live_feeds/live_feed.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="flashvars" value="appletroot=http://static.awempire.com/flash/live_feeds/&appletskin=template8/template01.swf&appletcol=900000&psid=ddany23&campaign_id=20520&pstour=t1&psprogram=REVS&site=jsm&flags=137438953473,137438953504,1,32&lp_lang=auto" /><embed src="http://static.awempire.com/flash/live_feeds/live_feed.swf" width="170" height="125" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" flashvars="appletroot=http://static.awempire.com/flash/live_feeds/&appletskin=template8/template01.swf&appletcol=900000&psid=ddany23&campaign_id=20520&pstour=t1&psprogram=REVS&site=jsm&flags=137438953473,137438953504,1,32&lp_lang=auto"></embed></object>');
});

$(".section").mouseleave(function() {
  $(this).html('ddd');
});


OK, this is completely off the top of my head, but actionscript can talk to javascript via flash.external.ExternalInterface. You can setup an EventListener in the flash movie that waits for the movie to finish loading, then fires a call to a JavaScript function. On the javascript side, simply create a global var (CanLoadMovie) and set it to false when you load a new Flash movie. Have the flash movie set that global var back to true when it completes. Only allow a new flash movie to be loaded when the CanLoadMovie is true. There is a gotcha there in that a flash movie that fails to load completely won't reset your CanLoadMovie, but there are ways to code around that. Like I said, this is just a quick, off the top of my head jumping off point, but hopefully it will get you started.

If you just want to "take a guess" in javascript on how long it takes to load, use javascript's setTimeout() to block flash loading and put up a spinner graphic if desired.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜