I'm trying to send a simple string to a Printer Server on our network.
The text is a language called ZPL which is going to our little print
server box that has a Zebra Label printer on its parallel port.

Here's my test app:


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">

     <mx:Script>
         <![CDATA[
             import mx.controls.Alert;


             private function onPrintZpl():void
             {
                 var sData:String = "^XA^FWR^CI13" +
                     "^LH<LabelTop>,<LabelLeft>" +
                     "^FWB^FO512,899^XGPPI_LAN,1,1^FS^FWR" +
                     "^FO708,045^A0,40,40^FDUnit 7^FS" +
                     "^FO659,042^A0,40,40^FDKuehne + Nagel Logistics^FS"
+
                     "^FO611,042^A0,40,40^FDAppletree Road^FS" +
                     "^FO562,042^A0,40,40^FDChipping Warden^FS" +
                     "^FO522,042^A0,40,40^FDBanbury^FS" +
                     "^FO476,042^A0,40,40^FDOxfordshire^FS" +
                     "^FO430,043^A0,40,40^FDOX17 1LL^FS" +
                     "^FO381,042^A0,40,40^FDUnited Kingdom^FS" +
                     "^BY3,3,10" +
                     "^FO141,043^B3R,N,100,Y,N^FD9999999999999^FS" +
                     "^XZ"

                 try
                 {
                     var socket:Socket = new Socket();

                     //socket.addEventListener(IOErrorEvent.IO_ERROR,
onIOError);

                     socket.connect("10.44.180.120", 9100);
                     socket.writeUTF(sData);
                     socket.flush();

                     socket.close();
                 }
                 catch(error:Error)
                 {
                     Alert.show(error.message);
                 }
             }

             private function onIOError(event:IOErrorEvent):void
             {
             }

         ]]>
     </mx:Script>

     <mx:VBox width="100%" label="Printing">
         <mx:Button label="ZPL Print" click="onPrintZpl()"/>
     </mx:VBox>

</mx:WindowedApplication>

With the app as it stands, I can hit the "ZPL Print" button, the label
is printed, but then the app throws this error:

[SWF] SocketTest.swf - 902,761 bytes after decompression
Error #2044: Unhandled IOErrorEvent:. text=Error #2031: Socket Error.
     at
SocketTest/onPrintZpl()[C:\Development\Monarch\Test\SocketTest\src\Socke\
tTest.mxml:28]
     at
SocketTest/___SocketTest_Button1_click()[C:\Development\Monarch\Test\Soc\
ketTest\src\SocketTest.mxml:58]

If I uncomment the call to addEventListener() for IOErrorEvent.IO_ERROR,
the app runs without any errors, but the label isn't printed.

Any comments/help gratefully received.

Thanks,

Ed.


Reply via email to