[flexcoders] Passing a varibable back to ActionScript via HTTPRequest

2008-12-18 Thread wkolcz
I have a CF page that generates a Unique ID (UUID). I have an
HTTPRequest passes information to a CF page and I want it to generate
the number and then return it to ActionScript where it can use it as a
local variable. Any idea on how to do that? 
Does the HTTPRequest return a value? Does it have to be in XML?

Would I set the returned value in the
resulthandler? Here is what I have for a HTTPRequest:

private function startTrackIt(trackInfo:Object):void {
var service:HTTPService = new HTTPService();
service.url = tracker.cfm; //Dev
service.method = POST; 
service.addEventListener(ResultEvent.RESULT, timingSaved);
service.addEventListener(FaultEvent.FAULT, alertFault);
service.send(trackInfo);
}

What
would I need to do next to set a local variable in my AS? In a
RemoteObject, I usually set the a variable, typed ArrayCollection, in
the ResultHandler.

Sorry, this little idea is all new me and I am trying to figure it out.

OR Can Flash create a unique number like ColdFusion?



RE: [flexcoders] Passing a varibable back to ActionScript via HTTPRequest

2008-12-18 Thread Tracy Spratt
An HTTPService call will return a value if the server process writes
back a response.

 

You can set the resultFormat=text.  I have never done this since I
always wrap my returned data in a status node: returnstatus
status=success, stausdescription= MyData/returnstatus

 

This give me a consistent data structure to work with even if there is a
problem on the server.

 

Retrieve you data and process it however you want in the timingSaved()
handler.

Private function timingSaved(event.ResultEvent):void

var xmlResult:XML = event.result as XML;

var sStatus:String = xmlResult.attribute(status);

if (sStatus == success) {

_sUId == xmlResult.text(); //set your instance var value or whatever

}

else  {

  Alert.show(xmlResult.attribute(statusdescription)Server Error);

Tracy

 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of wkolcz
Sent: Thursday, December 18, 2008 12:26 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Passing a varibable back to ActionScript via
HTTPRequest

 

I have a CF page that generates a Unique ID (UUID). I have an
HTTPRequest passes information to a CF page and I want it to generate
the number and then return it to ActionScript where it can use it as a
local variable. Any idea on how to do that? 
Does the HTTPRequest return a value? Does it have to be in XML?

Would I set the returned value in the resulthandler? Here is what I have
for a HTTPRequest:

private function startTrackIt(trackInfo:Object):void {
var service:HTTPService = new HTTPService();
service.url = tracker.cfm; //Dev
service.method = POST; 
service.addEventListener(ResultEvent.RESULT, timingSaved);
service.addEventListener(FaultEvent.FAULT, alertFault);
service.send(trackInfo);
}

What would I need to do next to set a local variable in my AS? In a
RemoteObject, I usually set the a variable, typed ArrayCollection, in
the ResultHandler.

Sorry, this little idea is all new me and I am trying to figure it out.

OR Can Flash create a unique number like ColdFusion?

 



Re: [flexcoders] Passing a varibable back to ActionScript via HTTPRequest

2008-12-18 Thread Nate Beck
Just out of curiosity..  Why wouldn't you use a CFC with access=remote?
 Then you could use the Flex mx:RemoteObject and pretty much be good to
go.
http://www.adobe.com/devnet/flex/flex_cf.html

has the information you need to accomplish such a thing.


On Thu, Dec 18, 2008 at 10:51 AM, Tracy Spratt tspr...@lariatinc.comwrote:

An HTTPService call will return a value if the server process writes
 back a response.



 You can set the resultFormat=text.  I have never done this since I always
 wrap my returned data in a status node: returnstatus status=success,
 stausdescription= MyData/returnstatus



 This give me a consistent data structure to work with even if there is a
 problem on the server.



 Retrieve you data and process it however you want in the timingSaved()
 handler.

 Private function timingSaved(event.ResultEvent):void

 var xmlResult:XML = event.result as XML;

 var sStatus:String = xmlResult.attribute(status);

 if (sStatus == success) {

 _sUId == xmlResult.text(); //set your instance var value or whatever

 }

 else  {

   Alert.show(xmlResult.attribute(statusdescription)Server Error);

 Tracy


  --

 *From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On
 Behalf Of *wkolcz
 *Sent:* Thursday, December 18, 2008 12:26 PM
 *To:* flexcoders@yahoogroups.com
 *Subject:* [flexcoders] Passing a varibable back to ActionScript via
 HTTPRequest



 I have a CF page that generates a Unique ID (UUID). I have an HTTPRequest
 passes information to a CF page and I want it to generate the number and
 then return it to ActionScript where it can use it as a local variable. Any
 idea on how to do that?
 Does the HTTPRequest return a value? Does it have to be in XML?

 Would I set the returned value in the resulthandler? Here is what I have
 for a HTTPRequest:

 private function startTrackIt(trackInfo:Object):void {
 var service:HTTPService = new HTTPService();
 service.url = tracker.cfm; //Dev
 service.method = POST;
 service.addEventListener(ResultEvent.RESULT, timingSaved);
 service.addEventListener(FaultEvent.FAULT, alertFault);
 service.send(trackInfo);
 }

 What would I need to do next to set a local variable in my AS? In a
 RemoteObject, I usually set the a variable, typed ArrayCollection, in the
 ResultHandler.

 Sorry, this little idea is all new me and I am trying to figure it out.

 OR Can Flash create a unique number like ColdFusion?

  




-- 

Cheers,
Nate

http://blog.natebeck.net