1 Reply Latest reply on Mar 12, 2013 2:55 AM by simonwidjaja

    Using API with Javascript

    TheJae

      Hi all, i've been trying to get this going for a week now and I am still unable to access the Edge Animate instane through Javascript.

       

      Here is the error I always get

      Uncaught TypeError: Object #has no method 'getComposition'

       

       

      And my code

       

      <!DOCTYPE html>
      <html>
      <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
                <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
                <title>complete_girl</title>
      <!--Adobe Edge Runtime-->
          <script type="text/javascript" charset="utf-8" src="complete_girl_edgePreload.js"></script>
                <script> 
                          var comp = AdobeEdge.getComposition("complete_Girl");
                          var stage = comp.getStage();
                </script>
          <style>
              .edgeLoad-complete_Girl { visibility:hidden; }
          </style>
      <!--Adobe Edge Runtime End-->
      
      
      </head>
      <body style="margin:0;padding:0;">
                <div id="Stage" class="complete_Girl">
                </div>
      </body>
      </html>
      
      

       

      It's weird that the documentation recommends using the following which wouldnt run at all:

      Edge.getComposition( compId )
        • 1. Re: Using API with Javascript
          simonwidjaja Level 1

          Hi theJae,

          I think I can help you with this one...

          The loading process of any Animate composition is asynchronous. Loading the "_edgePreload.js" file provides the global EdgeAnimate object but not the instantiated composition yet (asynch loading). So the solution is to use the bootstrap callback to wait for the composition to be loaded completely. I've built a demo with multiple compositions and interaction between them. It's a little more than you are actually looking for, but it demonstrates the usage of the bootstrap callback pretty good.

           

          http://temp.trendspurt.com/ec_sneakpeek/multi_compositions.zip

           

          BTW: "The Edge.* interface is available to use, but you should reference the global AdobeEdge variable if attempting to access the object from outside of the Edge Animate runtime."

           

          Hope that helps!

           

          Happy Coding,

          Simon Widjaja

          edgedocks.com

          edgecommons.org