flash - actionscript 3 return -


i new in actionscript 3 , have code doesn't work. can check it? want label1.text got input "hello world"

<?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009"                 xmlns:s="library://ns.adobe.com/flex/spark"                 xmlns:mx="library://ns.adobe.com/flex/mx" minwidth="955" minheight="600">     <fx:script>         <![cdata[             function onbutton1click():void {                 label1.text = login('irakli', 'password1');             }              function login(username:string, password:string){                 var loader:urlloader = new urlloader();                 var request:urlrequest = new urlrequest('http://localhost/hosting/index.php');                  request.method = urlrequestmethod.post;                 var variables:urlvariables = new urlvariables();                 variables.username = username;                 variables.password = password;                 request.data = variables;                  //handlers                 loader.addeventlistener(event.complete, _urlsended);                 loader.load(request);                  function _urlsended(e:event){                     var loader:urlloader = urlloader(e.target);                     return loader.data;                                      }             }         ]]>     </fx:script>     <s:button id="button1" x="193" y="118" label="button" click="onbutton1click();"/>     <s:label id="label1" x="223" y="166" text="label"/> </s:application> 

try this:

<?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009"                 xmlns:s="library://ns.adobe.com/flex/spark"                 xmlns:mx="library://ns.adobe.com/flex/mx" minwidth="955" minheight="600">     <fx:script>         <![cdata[             private function onbutton1click():void              {                 login('irakli', 'password1');             }              private function login(username:string, password:string):void             {                 service.send({username:username, password:password});             }              private function onloginresult(e:resultevent):void             {                 label.text = e.data string;             }         ]]>     </fx:script>     <fx:declarations>         <s:httpservice id="service" url="http://localhost/hosting/index.php" method="post" result="onloginresult(event)" />     </fx:declarations>     <s:button x="193" y="118" label="button" click="onbutton1click()"/>     <s:label id="label" x="223" y="166" text="label"/> </s:application> 

this isn't tested, should @ least.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -