I'd like to post a little plugin I've written which "queues" a method to be executed, then attempts to execute this method until successful.
This is useful when interacting with javascript-enabled (Flash/Javascript interaction) Flash objects created within jQuery's $.ready() method.. and probably has other utility. There is often a delay involved when embedding a new flash file with Luke Luteman's jQuery Flash plugin ( http://jquery.lukelutman.com/plugins/flash/ ) or SWFObject/UFO, and the javascript interaction methods will not be initialized, resulting in errors. So, here it is in readable form --> // flash queue function, attempt to fire a method until successful. Halts after 30 // consecutive failures. (function($) { $.fn.fq = function(m,p) { queue.push({ id:this[0], method:m, params: p}); fq = setInterval("$.fq()",100) return this; } $.fq = function() { var stop=false,h=queue[queue.length-1]; try { h.id[h.method](h.params); stop=true; queue.pop(); attempts = 0; } catch(e) {attempts++;} if(stop || queue.length == 0 || attempts > 30) clearInterval(fq); }; var queue=[],fq=false,attempts=0; })(jQuery); ---- For example, I've used it to mimick "autostart" functionality in Flash Video Player (http://www.jeroenwijering.com/?item=Flash_Video_Player) via; // reference the move (jQuery Flash/SWFObject injected <embed>||<object> tag) movie=$('embed',this).attr('id','ivpMovie'+i); // queue in methods movie.fq('sendEvent','playpause'); This is FIFO chainable.. e.g. movie .fq('sendEvent','playpause') .fq('sendEvent','mute'); I hope this helps someone. ~ Brice _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/