3 Replies Latest reply: Apr 15, 2012 1:04 PM by kglad RSS

    LocalConnection works when it should fail

    theErez Community Member

      Hi,

      in my page i have a main swf, which should check the existence of a second swf - if its missing, the main swf should display a certain message to the user, otherwise it should work as planned.

      i thought to achieve this by using LocalConnection - the main swf is set as the sending swf, and it should call a certain function on the other swf.  i was thinking that if the second swf is missing, the local connection would fail - either throw an error or its STATUS event listener would receive an 'error' message.

      if you think as i did - well think again.  no error was thrown and the listener got a 'status' message, although there's nobody to handle the LocalConnection 'send' method.

       

      what did i miss?  or is there a better way to achieve my goal?

      cheers,

      eRez

        • 1. Re: LocalConnection works when it should fail
          kglad MVP

          show your localconnetion code (only) including your statusevent listener.

          • 2. Re: LocalConnection works when it should fail
            theErez Community Member

            there you go:

            protected function onEnterFrame(event:Event):void

                    {

                      removeEventListener(Event.ENTER_FRAME, onEnterFrame);

                          ...

                      var conn:LocalConnection = new LocalConnection();

                      conn.addEventListener(StatusEvent.STATUS,onLCStatus);

                      conn.connect("toolbarCheck");

                      conn.send("toolbarCheck","checkForToolbar");

            }

             

            private function onLCStatus(event:StatusEvent):void

            {

                  if (event.level == "error")

                  {

                      // display message

                  }

                  else

                  {

                     // keep on going...

                  }

            }

             

            and as i mentioned - at this point, there isn't any other swf which handles this call

            • 3. Re: LocalConnection works when it should fail
              kglad MVP

              use:

               

               

              protected function onEnterFrame(event:Event):void

                      {

                        removeEventListener(Event.ENTER_FRAME, onEnterFrame);

                            ...

                        var conn:LocalConnection = new LocalConnection();

                        conn.addEventListener(StatusEvent.STATUS,onLCStatus);

                        //conn.connect("toolbarCheck");

                        conn.send("toolbarCheck","checkForToolbar");

              }

               

              private function onLCStatus(event:StatusEvent):void

              {

                    if (event.level == "error")

                    {

                        // display message

                    }

                    else

                    {

                       // keep on going...

                    }

              }