I have two flex apps and I would like to send a BitmapData object
between them.  The "Sender" application gets the BitmapData from a UI
object and sends it to the "Receiver" application.

"Sender" Application:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
        <mx:Script>
                <![CDATA[
                        import mx.controls.SWFLoader;
                        public function sendButtonImage():void{
                                var out_lc:LocalConnection = new 
LocalConnection();
                                var bitmapData:BitmapData;
                                bitmapData = new BitmapData(target.width, 
target.height);
                                bitmapData.draw(target,new Matrix());
                                out_lc.send("_foobar", "imageHandler", 
bitmapData);                             
                        }
                ]]>
        </mx:Script>
        <mx:Button id="target" x="10" y="10" label="Button"
click="{sendButtonImage()}"/>
</mx:Application>



"Receiver" Application:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute"
        applicationComplete="appComplete()">
        <mx:Script>
                <![CDATA[
                        import mx.controls.SWFLoader;
                        public var in_lc:LocalConnection;
                        public function appComplete():void{

                                in_lc = new LocalConnection();
                                in_lc.allowInsecureDomain("*");
                                in_lc.client = this;
                                in_lc.allowDomain("*");
                                in_lc.connect("_foobar");
                        }
                        public function imageHandler(foo:BitmapData):void{
                        }
                ]]>
        </mx:Script>
</mx:Application>


On the receiver side I get a type coercion error, saying:
"Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095:
flash.net.LocalConnection was unable to invoke callback imageHandler.
error=TypeError: Error #1034: Type Coercion failed: cannot convert
[EMAIL PROTECTED] to flash.display.BitmapData."

Can you not send a BitmapData object across a LocalConnection?  I
haven't seen anyone say this isn't possible so, I must be doing
something totally stupid.

thanks for any info.
-d



Reply via email to