0 Replies Latest reply on Jun 3, 2009 9:57 AM by creativemeasures

    Flash Builder 4 and PHP

    creativemeasures

      I am playing with the Flash Builder 4 beta, and I am trying to create a simple form element that refers to some php fuctions to return encoded or decode results.

       

      Here is the php sample of it: http://joshvh.com/test/data.php

       

      And here is the code:

       

      <?php
      
      static $binary;
      static $ascii;
      
      ?>
      <html>
      <head>
      <title>..: FOR ROBOT USE ONLY :..</title>
      <style>
      .ff{font-size: 10px;
          font-family:verdana,arial,helvetica,sans;
          color: #333333;
          background: #eee;
          }
      .btn{
          font-size: 8px;
          font-family:verdana,arial,helvetica,sans;
          color: #333333;
          background: #eee;
          }
      BODY{
      scrollbar-3dlight-color:#999999;
      scrollbar-arrow-color:#999999;
      scrollbar-base-color:#DDDDDD;
      scrollbar-darkshadow-color:#999999;
      scrollbar-face-color:#DDDDDD;
      scrollbar-highlight-color:#DDDDDD;
      scrollbar-shadow-color:#DDDDDD;
      scrollbar-track-color:#CCCCCC;
      }
      
      </style>
      
      </head>
      <body bgcolor="#ffffff" text="#000">
      
      <center>
      <table border=0 cellspacing=0 cellpadding=0><tr><td align=center>
      <font face="verdana,arial,helvetica" size=1>
      <h1>..: FOR ROBOT USE ONLY :..</h1>
      
      <table border=0 cellspacing=0 cellpadding=10>
      <tr><form method="POST"><td align=center valign=top>
      <font face="verdana,arial,helvetica" size=1>
      
      <b>[ HUMAN TEXT ]</b><br>
      <textarea cols=48 rows=15 wrap="virtual" name="ascii" class="ff"><?php
      
      set_magic_quotes_runtime(0);
      foreach($_POST as $key=>$val){ $$key = stripslashes($val); }
      
      #$_POST[ascii] = str_replace("\\'","'",$_POST[ascii]);
      #$_POST[ascii] = str_replace("\\\"","\"",$_POST[ascii]);
      #$_POST[ascii] = str_replace("\\\\","\\",$_POST[ascii]);
      if($ascii != "") print htmlentities($ascii);
      else {
      
      if($binary != "") {
          $binary_ = preg_replace("/[^01]/","", $binary);
          for($i = 0; $i < strlen($binary_); $i = $i + 8)
          $ascii = $ascii.chr(bindec(substr($binary_, $i, 8)));
      }
      
      if($hex != "") {
          $hex_ = preg_replace("/[^0-9a-fA-F]/","", $hex);
          for($i = 0; $i < strlen($hex_); $i = $i + 2)
          $ascii = $ascii.chr(hexdec(substr($hex_, $i, 2)));
      }
      
      if($b64 != "") {
          //$ascii = gzinflate($gzip);
          $ascii = base64_decode($b64);
      }
      
      if($char != "") {
          $char_ = preg_split("/\\D+/",trim($char));
          foreach ($char_ as $key)
          $ascii = $ascii.chr($key);
      }
      
      echo htmlentities($ascii);
      }
      
      ?></textarea>
      <br>
      <input type="submit" class="btn" value="&lt; ENCODE &gt;">
      </td></form><form method="POST"><td align=center valign=top>
      <font face="verdana,arial,helvetica" size=1>
      
      <b>[ BINARY ]</b><br>
      <textarea cols=48 rows=15 wrap="virtual" name="binary" class="ff"><?php
      
      if($binary != "") echo $binary;
      else if($ascii != "") {
      $val = strval(decbin(ord(substr($ascii, 0, 1))));
      echo str_repeat("0", 8-strlen($val)).$val;
      for($i = 1; $i < strlen($ascii); $i = $i + 1) {
      $val = strval(decbin(ord(substr($ascii, $i, 1))));
      echo " ".str_repeat("0", 8-strlen($val)).$val;
      }
      }
      
      ?></textarea>
      <br>
      <input type="submit" class="btn" value="&lt; DECODE &gt;">
      </td></form>
      <?
      function split32($text) {
          $string = "";
          for($i = 0; $i < strlen($text); $i = $i + 32) {
              $string = "$string\n  ".substr($text, $i, 32);
          }
          return $string;
      }
      function splitn($n,$text) {
          $string = "";
          for($i = 0; $i < strlen($text); $i = $i + $n) {
              $string = "$string\n  ".substr($text, $i, $n);
          }
          return $string;
      }
      ?>
      
      </body>
      </html>
      

       

       

      I have created the form elements and buttons, but I am struggling on figuring out how to bind the data in order for it to return results when the buttons are clicked. If anyone can help point me in the right direction, I would really appreciate the help.

       

      I can get by with the php stuff, it is the whole Flex interaction that I can not figure out.

       

      Thanks!

       

      Josh