I have an application developed in Flex 2 that loads another 
application built in Flash 8. Since they need to send some small 
data back and forth, I am using two LocalConnections - one for 
sending data from the Flex app to the Flash 8 app, and one for the 
reverse. Each uses a hard-coded name for simplicity's sake. All the 
data sent are intrinsics (Strings and Numbers)

So far, so good. Both sides send and receive the communications and 
the correct method calls are executed, but I've noticed some quirks 
with the arguments received by the functions on either side. On the 
Flex side, the client functions that take no parameters receive an 
argument array that looks like Array[Array[]] (an array of a single 
item which is an empty array), which throws a runtime error. On the 
Flash side, I've noted problems with the String objects where Flash 
cannot properly execute String methods on them. Also, in a function 
taking two String parameters (param1:String, param2:String), it is 
receiving param1='param1,param2' and param2=undefined from the 
LocalConnection. I've included sample code (including my 
workarounds) for all these cases below.

I've been unable to find any documentation or discussion mentioning 
any of these issues. Although they have fairly simple workarounds, 
it seems odd to find no mention of anything like this. Does anyone 
know if these are known issues, or am I missing something?

Thank you,
Heidi Hunter

// Sample Flex code
class LocalConnectionReceiver{
  // only one of these exists at any time
  private var connection:LocalConnection;

  function LocalConnectionReceiver(){
    connection = new LocalConnection();
    connection.client = this;
    connection.connect("flexLCListener");
  }

  // workaround for empty args array, I previously had
  // function onFlashResize():void{
  function onFlashResize(...arguments):void{
     // do something
  }
}

class LocalConnectionSender{
  // used by any Flex component needing to communicate with the 
Flash app
  private var connection:LocalConnection;

  public function send(method:String, ...arguments):void{
    connection.send("flash8LCListener",method,arguments);
  }
}

// Flash8/AS 2 code

class FlexConnector extends LocalConnection{
  function FlexConnector(){
    super();
    connect("flash8LCListener");
  }
  
  // I want to do :
  // function setInfo(param1:String, param2:String):Void {
  // but my workaround is:
  function setInfo( params:String ):Void{
    // I want to do:
    // var split:Array = params.split(",");
    // but I get split = undefined
    // workaround: 
    var paramString:String = String(params);
                
    var split:Array = paramString.split(",");
    var param1:String = split[0];
    var param2:String = split[1];
    
    // do something with param1 & param2
  }

  function sendToFlex(method:String):Void{
    var sendConnection:LocalConnection = new LocalConnection();
    sendConnection.send("flexListener",method,arguments.slice(1));
  }
}







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to