3 Replies Latest reply on Jul 20, 2007 10:01 AM by Newsgroup_User

    ExternalInterface for Scorm 1.2 LMS Communication

    OrangeHaze
      Hello, I've been doing a large amount of research concerning Flash <-> LMS communication via ExternalInterface. Originally ExternalInterface was not even an option for my company, since our client requested the SCO be published in Flash 7, but we have recently convinced them to upgrade to Flash 8 (and I'm actually still pushing for Flash 9).


      The decision I am facing is whether or not I should implement the ExternalInterface class, or should I just stick with the old FSCommand. I understand that the ExternalInterface is a no-brainer if you need to support browsers other than IE; however, that is not the case for us because our LMS provider only supports IE.

      Personally I would like to start using ExternalInterface because Adobe seems to advocate it as the best way to communicate with Javascript, but I've read an article that says ExternalInterface is much slower than FSCommands or GetURLs (in milliseconds at least), and I also wanted to investigate and find out if anyone has implemented ExternalInterface when working with a Javascript Runtime Wrapper.

      I also understand that ExternalInterface is synchronous, so does that mean my SWF is guaranteed to receive the LMS's variables back, or at least more consistently than FSCommands?

      If anyone has some experience on this subject, I would greatly appreciate your input. Until then I am thinking about just replacing the FSCommands with a ExternalInterface.call() method, and passing my variables to the Javascript Function responsible for hooking the FSCommands (I believe it is MovieName_DoFSCommand()), and letting Javascript take care of setting the variables I pass it. Although if I do this, I fear I might missing out on the benefits of the synchronizing unless I rewrite the Javascript function so it returns a value immediately instead of using SetVariable() on the movie object. Please let me know what you think!!
        • 1. Re: ExternalInterface for Scorm 1.2 LMS Communication
          Level 7
          Hi OrangeHaze,

          ExternalInterface usage really hangs on one thing: serialization. The
          EI system does automatic data serialization in/out of Flash. That is,
          when you create an Object instance in Flash, JavaScript gets it as an
          object. When you create a Number, a number is received in JavaScript.
          This is where the majority of the processing overhead comes from. Yes,
          ExternalInterface makes it a bit easier to invoke functions
          bi-directionally, and it does have the neat feature of returning values
          directly from function invocation rather than asynchronously, but other
          than that there's not much else to it.

          So, if you are only ever passing strings between Flash and JavaScript
          and only call a handfull of functions, fscommand and getURL are better
          because that entire step of cross-converting values (using XML as
          intermediary) is avoided. However, if you need flexibility,
          ExternalInterface is just the thing. It is not the ONLY thing, though.
          I've made extensive use of JSON in past code and I think that it could
          be argued that it has advantages. It also does serialization but it does
          it to a native serialized format of JavaScript. This means that the
          processing overhead for JSON is considerably less than for
          ExternalInterface. For sheer speed, JSON is great, but for flexibility,
          it could still use some work. Adding a callback, for example, is not
          something that's built into JSON because it's so generic. Also, direct
          function call return values are not supported like they are in
          ExternalInterface. So the decision is basically one that involves three
          factors:

          1. If you want sheer speed, only call a few functions, and parameters
          are only ever strings: use getURL or fscommand
          2. If you want greatest flexibility and integration, most native
          language support, and ease of use: use ExternalInterface
          3. If you want a mixture between speed and integration but with less of
          each than #1 and #2: use JSON

          Hope that was helpful.

          Regards,
          Patrick

          --
          http://www.baynewmedia.com
          Faster, easier, better...ActionScript development taken to new heights.
          Download the BNMAPI today. You'll wonder how you ever did without it!
          Available for ActionScript 2.0/3.0.



          OrangeHaze wrote:
          > Hello, I've been doing a large amount of research concerning Flash <-> LMS
          > communication via ExternalInterface. Originally ExternalInterface was not even
          > an option for my company, since our client requested the SCO be published in
          > Flash 7, but we have recently convinced them to upgrade to Flash 8 (and I'm
          > actually still pushing for Flash 9).
          >
          >
          > The decision I am facing is whether or not I should implement the
          > ExternalInterface class, or should I just stick with the old FSCommand. I
          > understand that the ExternalInterface is a no-brainer if you need to support
          > browsers other than IE; however, that is not the case for us because our LMS
          > provider only supports IE.
          >
          > Personally I would like to start using ExternalInterface because Adobe seems
          > to advocate it as the best way to communicate with Javascript, but I've read an
          > article that says ExternalInterface is much slower than FSCommands or GetURLs
          > (in milliseconds at least), and I also wanted to investigate and find out if
          > anyone has implemented ExternalInterface when working with a Javascript Runtime
          > Wrapper.
          >
          > I also understand that ExternalInterface is synchronous, so does that mean my
          > SWF is guaranteed to receive the LMS's variables back, or at least more
          > consistently than FSCommands?
          >
          > If anyone has some experience on this subject, I would greatly appreciate your
          > input. Until then I am thinking about just replacing the FSCommands with a
          > ExternalInterface.call() method, and passing my variables to the Javascript
          > Function responsible for hooking the FSCommands (I believe it is
          > MovieName_DoFSCommand()), and letting Javascript take care of setting the
          > variables I pass it. Although if I do this, I fear I might missing out on the
          > benefits of the synchronizing unless I rewrite the Javascript function so it
          > returns a value immediately instead of using SetVariable() on the movie object.
          > Please let me know what you think!!
          >
          >
          > ExternalInterface.call("Main_DoFSCommand", "LMSGetValue",
          > "cmi.suspend_data,_root.vModStatus");
          >
          • 2. Re: ExternalInterface for Scorm 1.2 LMS Communication
            OrangeHaze Level 1
            Thanks for your reply Patrick. I actually just created a speed test between External Interface and FScommands where a return value is needed. With EI you just add a return statement to your Javascript function, and with FS you need to modify a flash variable via Javascripts SetVariable() function. It seems that ExternalInterface came out on top; however, the test included 100 to 10000 consecutive calls to each, which is not really practical.
            • 3. Re: ExternalInterface for Scorm 1.2 LMS Communication
              Level 7
              I have to say I'm honestly surprised. I' assumed that fscommand was
              faster by sheer virtue of simplicity. Well, that's a good argument I can
              make in favour of EI with clients in the future. Thanks for running the
              tests, OH.

              Patrick

              OrangeHaze wrote:
              > Thanks for your reply Patrick. I actually just created a speed test between
              > External Interface and FScommands where a return value is needed. With EI you
              > just add a return statement to your Javascript function, and with FS you need
              > to modify a flash variable via Javascripts SetVariable() function. It seems
              > that ExternalInterface came out on top; however, the test included 100 to 10000
              > consecutive calls to each, which is not really practical.
              >

              --
              http://www.baynewmedia.com
              Faster, easier, better...ActionScript development taken to new heights.
              Download the BNMAPI today. You'll wonder how you ever did without it!
              Available for ActionScript 2.0/3.0.