?
Solved

How do I bind the result of HTTPService to a HTML component...

Posted on 2008-11-18
4
Medium Priority
?
255 Views
Last Modified: 2013-11-11
Dear Experts,

How do I bind or direct the results of either HTTPService requests to the HTML component?



<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>


<![CDATA[

import mx.controls.Alert;

private function Login():void {
      
        httpSvcLogin.send();
       
}
private function User():void {
      
       
        httpAdduser.send();
}
 
]]>
</mx:Script>


<mx:HTTPService resultFormat="e4x"  id="httpSvcLogin" url="http://localhost/index.php?login=check" showBusyCursor="true" useProxy="false" method="POST">
      <mx:request xmlns="">
      <username>admin</username>
      <password>1234</password>
      </mx:request>
</mx:HTTPService>

<mx:HTTPService resultFormat="e4x"  id="httpAdduser" url="http://l/index.php?sec=user" showBusyCursor="true" useProxy="false" method="POST">
      <mx:request xmlns="">
          <action>add</action>
          <username>Joel+Sisko</username>
      </mx:request>
</mx:HTTPService>


<mx:Button x="22" y="10" label="login" click="Login();"/>
<mx:Button x="83" y="10" label="Add User" click="User();"/>
<mx:HTML width="100%" height="100%" y="40"/>

</mx:WindowedApplication>
0
Comment
Question by:Joel_Sisko
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
evcr earned 2000 total points
ID: 22993406
See below,

However I cannot see the point of doing it this way when you can just point the html to the url of those pages.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 
<mx:Script>
 
 
<![CDATA[
 
import mx.controls.Alert;
import mx.events.*
 
private function Login():void {
	httpSvcLogin.send();
}
private function User():void {
	httpAdduser.send();
}
 
private function loginResult(event:Event):void {
	htmlWindow.htmlText = httpSvcLogin.lastResult.toString();
}
 
private function userResult(event:Event):void {
	htmlWindow.htmlText = httpAdduser.lastResult.toString();
}
 
]]>
</mx:Script>
 
 
<mx:HTTPService result="loginResult(event)" resultFormat="e4x" id="httpSvcLogin" url="http://localhost/eedemos/test.php" showBusyCursor="true" useProxy="false" method="POST">
      <mx:request xmlns="">
      <username>admin</username>
      <password>1234</password>
      </mx:request>
</mx:HTTPService>
 
<mx:HTTPService result="userResult(event)" resultFormat="e4x" id="httpAdduser" url="http://localhost/eedemos/test.php" showBusyCursor="true" useProxy="false" method="POST">
      <mx:request xmlns="">
          <action>add</action>
          <username>Joel+Sisko</username>
      </mx:request>
</mx:HTTPService>
 
 
<mx:Button x="22" y="10" label="login" click="Login();"/>
<mx:Button x="83" y="10" label="Add User" click="User();"/>
<mx:HTML width="100%" height="100%" y="40" id="htmlWindow"/>
 
</mx:WindowedApplication>

Open in new window

0
 
LVL 12

Author Comment

by:Joel_Sisko
ID: 22994881
If I use the location parameter the for the HTML component, is that not a separate session from the HttpService  that is sending the request?

Joel
0
 
LVL 12

Author Comment

by:Joel_Sisko
ID: 22995094
It did what I needed it to do. Thanks for all the help once again.

Question on the return resultFormat, should it be "text" or "e4x" or something else?

Joel
0
 
LVL 7

Expert Comment

by:evcr
ID: 22996178
q1. I think if you look through the html component that's proabably what it does.

q2. I think it should be text, as it's not xml your returning.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question