6 Replies Latest reply: Oct 5, 2010 10:03 PM by Flex Rock RSS

    Load an External Php variable into Actionscript in flex.

    dinulawki

      Hi,

       

      i have being trying to load an external variable from a php file into a actionscript variable.i know how to bind php data from mysql to datagrid but this is not what im looking for,Example say a varaible in php has value =5, this value should be passed to a actionscript variable limit,so now limit will have value 5.

       

      I am using flex 3 and i have tried lot of examples listed on google,i have gone through all the tutorials,codes..etc..all of them were made using cs3 or cs4.And when i ran them i dint get any output at all.Either i got thatproperty  loader wasnt defined or nothing in my textarea.

       

      if possible please guide me on the following or kindly give a small sample that works on flex3.i am also not sure of what i shud write in my php file.

       

      i have added the code of my mxml file for this which is not working and shows me a blank textarea.

       

      Any help would be appreciated..thanks in advance

       

       

       

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="httw://www.adobe.com/2006/mxml" xmlns:custom="test.external.*" layout="absolute" initialize="load()">
      <mx:Script>
      <![CDATA[

      private function load() : void {
        var loader:URLLoader = new URLLoader();
        loader.addEventListener(Event.COMPLETE, onComplete);
        loader.load(new URLRequest(https://localhost/external.php)); 
      }

      private function onComplete(e:Event):void {
        ext.text = URLLoader(e.target).data; 
      }

       



      ]]>
      </mx:Script>
      <mx:TextArea id="ext" x="296" y="199" >

       


      </mx:TextArea>
      <mx:Button click="load()" x="343.5" y="274">

      </mx:Button>
      </mx:Application>