<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,4 @@
-== LzOsUtils Changes
-
-* Flashbridge proxies and sync
-* Docs
+= LzOsUtils Changes
 
+== 2008-05-01
+* FlashBridge: increased the timeout; add tracing, options parameter</diff>
      <filename>CHANGES</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,33 @@
 /* Copyright 2006-2008 by Oliver Steele.  All rights reserved. */
 
 // DON'T CALL ME.  Use +FlashBridge.initialize+ to set up the bridge.
-function FlashBridge(id) {
+function FlashBridge(id, options) {
     var self = this;
+    options = options || {};
+    this.trace = options.trace;
+    
     // swfobject, unlike flashobject, inserts the object tag
-    // asynchronously.  Give it a few frames to do its work.
-    var count = 10,
+    // asynchronously.  Give it a few frames to work (default 12K retries
+    // * 50ms/retry = 10m).
+    var retries = options.retries || 12000,
         thread = setMovieObject() || setInterval(function() {
-            if (setMovieObject())
-                return clearInterval(thread);
-            if (--count &lt;= 0) {
-                window.console &amp;&amp; console.error &amp;&amp; console.error('no id=' + id);
+            self.info('Looking for #' + id + ': ' + retries + ' retries left');
+            if (setMovieObject()) {
                 clearInterval(thread);
+                self.info('Found #' + id);
+                return;
             }
-        }, 10);
+            if (--retries &gt; 0)
+                return;
+            clearInterval(thread);
+            self.info('Looking for #' + id + ': timed out');
+            (options.loaderror || function() {
+                window.console &amp;&amp; console.error &amp;&amp;
+                    console.error('FlashBridge failed to find #' + id);
+            })();
+        }, options.retryInterval || 50);
     // Even if the movie has loaded, it may not have registered the
-    // necessary methods.  +synchronize+ queues calls to it until it
+    // necessary methods.  +synchronize+ queues calls it until it
     // responds to a ping.
     this.callWithoutCapturing = this.call;
     this.synchronize();
@@ -33,12 +45,17 @@ function FlashBridge(id) {
 // &quot;becomes singleton&quot; pattern.  Replaces the class by an instance
 // attached to a particular movie.  There is no current support for
 // multiple FlashBridge instances (say, attached to multiple objects).
-FlashBridge.initialize = function(id) {
-    FlashBridge = new FlashBridge(id);
+FlashBridge.initialize = function(id, options) {
+    FlashBridge = new FlashBridge(id, options);
+}
+
+FlashBridge.prototype.info = function(msg) {
+    this.trace &amp;&amp; console.info('FlashBridge: ' + msg);
 }
 
-FlashBridge.prototype.call = function(name) {
+FlashBridge.prototype.call = function(functionName) {
     var target = this.object,
+        name = functionName,
         args = arguments,
         alwaysLookupMethod = true;
     if (name.indexOf('.') &gt;= 0 || alwaysLookupMethod) {
@@ -63,7 +80,10 @@ FlashBridge.prototype.call = function(name) {
         body.push(')');
         fn = delegators[args.length] = new Function('name', body.join(''));
     }
-    return fn.apply(this, args);
+    var t0 = new Date;
+    fn.apply(this, args);
+    this.trace &amp;&amp; console.info('FlashBridge: call', functionName, arguments)
+    this.time &amp;&amp; console.info('FlashBridge:', functionName, new Date - t0);
 }
 
 FlashBridge.prototype.define = function(name, fn) {
@@ -171,19 +191,21 @@ FlashBridge.prototype.synchronize = function(timeout) {
             return clearInterval(thread);
         if (new Date - startTime &gt; timeout) {
             clearInterval(thread);
-            console.error('FlashBridge initialization timed out');
+            console.error('initialization timed out');
         }
         self.sendPing();
     }, 1000);
 }
 
 FlashBridge.prototype.sendPing = function() {
+    this.info('ping');
     var target = this.object;
     if (target &amp;&amp; target.handleFlashbridgePing)
         target.handleFlashbridgePing();
 }
 
 FlashBridge.prototype.handlePong = function() {
+    this.info('pong');
     this.stopCapturingCalls();
     this.playCapturedCalls();
 }</diff>
      <filename>lib/flashbridge-browser.js</filename>
    </modified>
    <modified>
      <diff>@@ -109,8 +109,12 @@ FlashBridge.handleCall = function(path) {
  * Synchronization
  */
 
+FlashBridge.sendPong = function() {
+    FlashBridge.callWithoutQueue('FlashBridge.handlePong');
+}
+
 FlashBridge.handlePing = function() {
-    FlashBridge.call('FlashBridge.handlePong');
+    this.sendPong();
     this.call = this.callWithoutQueue;
     this.playQueue();
 }</diff>
      <filename>lib/flashbridge-plugin.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8b5a293938564d5c5660c328d60158ac5d313d47</id>
    </parent>
  </parents>
  <author>
    <name>Oliver Steele</name>
    <email>steele@osteele.com</email>
  </author>
  <url>http://github.com/osteele/lzosutils/commit/c8f0e8dbfbdc123e37dcfcbc0243340b82d40972</url>
  <id>c8f0e8dbfbdc123e37dcfcbc0243340b82d40972</id>
  <committed-date>2008-05-01T03:14:21-07:00</committed-date>
  <authored-date>2008-05-01T03:14:21-07:00</authored-date>
  <message>increased the timeout; add tracing, options parameter</message>
  <tree>1f76f9e1aaf6cf490de35033162ca90a91857d23</tree>
  <committer>
    <name>Oliver Steele</name>
    <email>steele@osteele.com</email>
  </committer>
</commit>
