2 Replies Latest reply on Aug 18, 2006 11:49 AM by jdariasl

    Events handlers in JavaScript

    jdariasl
      Hi!

      I'm evaluating director, using VbScriptXtra to connect COM objects with director.

      With this xtra, I can do this in lingo:
      -- Event Handler class this is in one script
      on new me
      return me
      end
      on OnErrorEvent me, args
      alert("OnErrorEvent fired")
      end
      on OnResponseEvent me,args
      alert("OnErrorEvent fired")
      end
      -- End Event Handler class

      -- Caller class (In another script)
      on new me
      me.objCOMIntegrator = xtra("VbScriptXtra").CreateObject("boinkIntegrator.clsIntegrator")
      me.objCOMIntegrator.EventsHandler = new(script("comEventHandler"))
      end
      -- End caller class

      This works fine in my application and I Can recive events from my COM library.

      I want to translate to JavaScript. Here is my code:
      -- Event Handler class

      function comEventHandler()
      {
      this.OnErrorEvent = OnErrorEvent;
      this.OnResponseEvent = OnResponseEvent;
      }
      function OnErrorEvent(args)
      {
      _player.alert("OnErrorEvent fired");
      }
      function OnResponseEvent (args)
      {
      _player.alert("OnResponseEvent fired");
      }
      -- End Event Handler class
      -- Caller Class
      function clsController()
      {
      this.objCOMIntegrator = xtra("VbScriptXtra").CreateObject("boinkIntegrator.clsIntegrator");
      trace("Creando el objeto clsController");
      this.objCOMIntegrator.EventsHandler = new comEventHandler();
      }
      -- End Caller class

      This not work and I don't know why.

      The xtra provider answer me this:
      "In general, it is possible to use JS with VbScriptXtra, but some limitations are applied by Director itself. The problem is that Director does not allow xtra to properly handle JS class object from the xtra level. So events handling works only with parent script instances or sprite behaviours. It should be set with something like:
      me.objCOMIntegrator.EventsHandler = new(script("comEventHandler"))

      When you use:
      this.objCOMIntegrator.EventsHandler = new comEventHandler();"

      It’s possible to do what we already do in lingo, in JavaScript

      I'll thank any help

      Regards,

      Jorge Dario Arias
      Software Engineering
      Boink System Inc.
      www.boink.com
        • 1. Re: Events handlers in JavaScript
          Level 7
          Well, then don't use the javascript version. It's just to get Flash users to
          try Director.

          ">
          > This works fine in my application and I Can recive events from my COM
          > library.
          >
          > I want to translate to JavaScript. Here is my code:
          > -- Event Handler class
          >
          >
          > This not work and I don't know why.
          >
          > The xtra provider answer me this:
          > "In general, it is possible to use JS with VbScriptXtra, but some
          > limitations
          > are applied by Director itself. The problem is that Director does not
          > allow
          > xtra to properly handle JS class object from the xtra level. So events
          > handling
          > works only with parent script instances or sprite behaviours. It should be
          > set
          > with something like:
          > me.objCOMIntegrator.EventsHandler = new(script("comEventHandler"))
          >
          > When you use:
          > this.objCOMIntegrator.EventsHandler = new comEventHandler();"
          >
          > It?s possible to do what we already do in lingo, in JavaScript
          >
          > I'll thank any help
          >
          > Regards,
          >
          > Jorge Dario Arias
          > Software Engineering
          > Boink System Inc.
          > www.boink.com
          >
          >


          • 2. Re: Events handlers in JavaScript
            jdariasl Level 1
            But our company already knows javascript and it is better for us work with javascript rather than lingo. Can we use both languages in the same movie?