Skip navigation
Currently Being Moderated

Load an External Php variable into Actionscript in flex.

Oct 4, 2010 9:55 AM



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://" xmlns:custom="test.external.*" layout="absolute" initialize="load()">

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(; 


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


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





  • Currently Being Moderated
    Oct 4, 2010 1:35 PM   in reply to dinulawki

    Does your service work when called in the browser?


    Mark as:
  • Currently Being Moderated
    Oct 5, 2010 5:14 AM   in reply to dinulawki

    Why can't you use HTTPService instead of URL loader. It has result event using the result event you can get the value from php file.




    Mark as:
  • Currently Being Moderated
    Oct 5, 2010 10:03 PM   in reply to dinulawki


        You can try this.


    <mx:HTTPService url="https://localhost/external.php" method="POST" useProxy="false" id="httpService"
                resultFormat="text" result="resultHandler(event)"/>



    public function resultHandler(evt:ResultEvent):void
                    var res:String=evt.result as String


    Instead of res you can use your variable to assign the php result.





    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points