1 Reply Latest reply on Nov 25, 2009 2:25 PM by pauland

    Can I use Perl with Flex?

    forsythes

      I would like to run several Perl scripts from Flex. Following the only example I found online, I have the files/code listed below. The problem is, when I test locally, I get nothing as the message. When I upload to my server, I also get nothing as the message. Perl seems to be installed properly on the server. Other scripts in the directory run fine. Also, the Perl script below runs fine when I run it through command line. So... I'm very confused as to if this can even be done.

       

       

      main.mxml

      -----------------

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
           <mx:Script>
           <![CDATA[
               private function onResult():void
               {
                   txt.htmlText = txt.htmlText + "<br/>Msg1: " + xmlService.lastResult.messages["msg1"];
                   txt.htmlText = txt.htmlText + "<br/>Msg2: " + xmlService.lastResult.messages["msg2"];
               }           
           ]]>
           </mx:Script>
           <mx:HTTPService id="xmlService" result="onResult();" resultFormat="e4x" url="test_IO.pl" />
           <mx:Panel width="350" height="280" layout="absolute" horizontalCenter="0" verticalCenter="0" color="#000000" fontSize="12" fontFamily="Verdana">
               <mx:Button x="126.5" y="10" label="Test Me" click="xmlService.send();"/>
               <mx:TextArea x="10" y="42" width="310" height="188" id="txt" verticalScrollPolicy="on"/>
           </mx:Panel>
      </mx:Application>

       

       

       

      test_IO.pl

      ------------------

      #!/usr/bin/perl

       

      use strict;

       

      use XML::Writer;

       

      print "Content-type: text/xml\n\n";

       

      my $xml = new XML::Writer();

       

      $xml->startTag("root");

       

        $xml->startTag("messages");

       

          $xml->dataElement(msg1=> "Hello World");

       

          $xml->dataElement(msg2=> "Goodbye World");

       

          $xml->endTag();

       

          $xml->endTag();

       

      $xml->end();