Hej Guy and Gals,

I need some help getting localConnection to work. I have a Flex app
running in the browser and an air app running on my desktop. Im trying
to call a method on the air app from the flex app. I keep getting the
dratted

Error #2044: Unhandled StatusEvent:. level=error, code=

error. Ive searched the net and not found anything that helps. Any ideas
would be appreaciated. BTW im running both these from Flex Builder. Have
also tryed running them from an air installation/web server. Heres the
code:

Thanks!


/***********************************************************************\
*******/
/********************* Flex App
************************************************/
/***********************************************************************\
*******/
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="init()" width="319" height="299">
     <mx:Script>
     <![CDATA[
     import flash.net.LocalConnection;

     private var conn:LocalConnection;

     private function init():void{

         conn = new LocalConnection();
         conn.addEventListener(StatusEvent.STATUS, status);
         conn.allowDomain('*');
         conn.client = this;
     }

     private function InitConn():void{
         textareaTasks.text += "sending message\n";
         conn.send("connId", "handler");
     }

     private function status(e:StatusEvent):void{
         textareaTasks.text += e.level + "\n";
     }

     ]]>
     </mx:Script>
     <mx:Panel paddingLeft="20" paddingRight="20" paddingBottom="20"
paddingTop="20"
     height="100%" width="100%" title="Send Message">
     <mx:Label text="Status output:"/>
     <mx:TextArea id="textareaTasks" width="100%" height="100%"/>
     <mx:Button id="connectagain" click="InitConn( )" label="Send
Message"/>
     </mx:Panel>
</mx:Application>



/***************************************************************/
/********************** AIR APP ********************************/
/********************** ****************************************/
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml";
     layout="absolute"
      width="351" height="261">
     <mx:Script>
     <![CDATA[
         import mx.controls.Alert;
         import flash.net.LocalConnection;

         private var conn:LocalConnection;

         private function initConn():void{
             conn = new LocalConnection();
             conn.addEventListener(StatusEvent.STATUS, onStatus);
             conn.allowDomain('*');
             conn.client = this;
             conn.connect("connId");
             labelStatus.text = "connected to 'connId' \n";
         }

         public function handler(event:MouseEvent):void {
             labelStatus.text += "Got a message\n";
         }

         private function onStatus(event:StatusEvent):void {
             trace(event);
             switch (event.level) {
                 case "status":
                 labelStatus.text += "LocalConnection.send()
succeeded\n";
                 break;
                 case "error":
                 labelStatus.text += "LocalConnection.send() failed\n";
                 break;
             }
         }

     ]]>
     </mx:Script>
     <mx:Panel horizontalCenter="0" verticalCenter="0" width="100%"
height="100%" cornerRadius="0" paddingBottom="20" paddingLeft="20"
paddingRight="20" paddingTop="20">
         <mx:Label text="Status output:"/>
         <mx:TextArea width="100%" height="100%" id="labelStatus"/>
         <mx:Button label="Connect" click="initConn()"/>
     </mx:Panel>

</mx:WindowedApplication>


Reply via email to