<?xml version="1.0" encoding="UTF-8"?>
<Module>
  <ModulePrefs title="Flash Caja Demo"
      height="200" 
      description="Demonstrates the use of caja to protect flash gadgets and the flash bridge">
    <Require feature="caja"></Require>
    <Require feature="flash"></Require>
    <Require feature="dynamic-height"></Require>
  </ModulePrefs>
  <Content type="html">
  <![CDATA[
  Caja does not allow <code>object</code> or <code>embed</code> tags
  in HTML.  However, Shindig provides a tamed JavaScript API for
  embedding flash on a page.  To embed a flash file, use
  <code>Require feature="flash"</code> in your
  ModulePrefs and <code>gadges.flash.embedFlash</code> in the body of
  your gadget to embed flash.
  <p>
  This example illustrates the use of the flash bridge for enabling
  communication between the sandboxed flash and the cajoled gadget.
  <p>
  The sources for this example are on the <a href="http://code.google.com/p/google-caja/downloads/list">Caja downloads page</a>: 
  <a href="http://google-caja.googlecode.com/files/Boxed.as">Boxed.as</a>, 
  <a href="http://google-caja.googlecode.com/files/Boxed.fla">Boxed.fla</a>
  <div id="flashcontainer" style="width:200; height: 200">
    You need Flash player 10 and JavaScript enabled to view this video.
  </div>
  <button id="btn" onclick='bridge.callSWF("mySWFMethod", [5,6,7]);' disabled>mySWFMethod(5,6,7)</button>
  <div id="result"></div>

  <script>
    var bridge;
    function onFlashBridgeReady() {
      bridge = gadgets.flash.embedFlash(
          "http://caja.appspot.com/Boxed.swf",
          "flashcontainer",
          10);
      document.getElementById('btn').disabled = false;
      gadgets.window.adjustHeight();
    }
    
    function myJSMethod(x, y, z) {
      document.getElementById("result").innerHTML += "myJSMethod("+[x,y,z]+")<br>";
      gadgets.window.adjustHeight();
    }
    gadgets.window.adjustHeight();
  </script>
  ]]>
  </Content>
</Module>
