5 Replies Latest reply on Feb 21, 2009 11:56 AM by Rob DiCiuccio

    LocalConnection in Projector?

    Rob DiCiuccio
      Is anyone aware of a method to enable LocalConnection communication listening in a Director projector on Mac? I've successfully enabled LocalConnection communication with external SWFs when the Director file is run as a .dcr through the browser, but when compiled as a projector, it does not respond to any connections, and the calling SWF returns an error. In this scenario, the SWF is sending the request, and the DIR is listening for requests.

      Code posted below, any help would be greatly appreciated.

      SW: Director MX 2004, Mac OS 10.5.6

      ### DIR source: ###

      global gLocalConn
      global gConnName

      on startMovie (me)

      -- set connection name
      gConnName = "testConn"

      -- step 1: create the LocalConnection object
      -- using a global Flash object
      gLocalConn = newObject("LocalConnection")

      -- step 2: declare the allowDomain and onStatus
      -- callback functions

      -- step 3: declare a custom callback function

      -- step 4: connect the LocalConnection object
      tConnResult = gLocalConn.connect(gConnName)

      -- check for connection failure
      if not(tConnResult) then

      -- clear the reference (we will navigate back to the first frame on exitFrame)
      gLocalConn = VOID
      member("output").text = "Connection failed"

      member("output").text = "My domain: " & gLocalConn.domain()

      end if

      end startMovie

      on allowDomain (me, aLocalConnObj, aDomain)

      member("output").text = member("output").text & RETURN & "allowDomain"

      -- for our demo purposes always return true
      member("output").text = member("output").text & RETURN & aDomain
      --return TRUE

      end allowDomain

      on onStatus (me, aLocalConnObj, aInfoObject)

      -- check for an error in the outgoing message
      if (aInfoObject.level = "error") then
      -- update the chat input with an error message
      member("output").text = "< onStatus:error >"
      -- do something
      member("output").text = "Status: " & aInfoObject.level
      end if

      end onStatus

      on commandProxy (me, aLocalConnObj, aCmd)

      member("output").text = "commandProxy"

      -- append the incoming message to the output display
      member("output").text = member("output").text & RETURN & aCmd

      end commandProxy

      ### Actionscript: ###

      var lc:LocalConnection = new LocalConnection();

      lc.send("testConn","commandProxy","hello world");

      lc.addEventListener(StatusEvent.STATUS, onStatus);

      function onStatus(event:StatusEvent):void {
      trace("STATUS: " + event.level + ": " + event.code);