Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Dataset from Server 1

Status
Not open for further replies.

ToddWW

Programmer
Mar 25, 2001
1,073
US
I am a fairly new to Flash and OOP. I am working on a project that has us at the point where we are communicating with the server. I am familiar with the various methods to communicate Flash with external data.

I have studied many tutorials, books, and both the Flash and ASP forums on this site and I have yet to come up with suggestions for returning datasets (multiple records) from a server to flash.

Here, my goal is to send a request to the server to return some basic information about the top 20 news stories stored in the server. I have come up with an un-tested solution and thought I would get some advice from the experts to see if I am even going down the right road for this type of need.

Code:
var serverURL:String = "[URL unfurl="true"]http://www.myserver.com/news.cgi"[/URL]

on (release) {
  
// Creates an XML object <newsrequest category="sports" />
  xmlReq = new XML();
  xmlElement = xmlReq.createElement("newsrequest");
  xmlElement.attributes.category = "sports";
  xmlReq.appendChild(xmlElement);

// Creates an XML object for the server's reply
  xmlReply = new XML();
  xmlReply.onLoad = onServerReply;  

// Sends the XML to the Server
// Reply goes into the xmlReply object
  xmlReq.sendAndLoad(serverURL,xmlReply);

}

function onServerReply() {
  // Use various XML Class methods to iterate through
  // the XML DataSet and create Flash Objects, etc..
}

This would be designed to parse a dataset that could contain hundreds of records (my reason for asking if this is the best method for that requirement). For this example, the return XML dataset would look something like this.

Code:
<news>
  <story id="65122341" subject="St. Louis Wins World Series" date="11/15/06" />
  <story id="15234421" subject="San Diego get's ready for Denver" date="12/05/06" />

  // and so on .... up to 100s of records.

<news>

Lastly, how would I destroy the XML objects when I am finished with them to free up memory on the client's machine.

Your help is greatly appreciated.

ToddWW
 
In order to destroy the XML object, you can do:

delete xmlReq

However, ActionScript "delete" actually does not offload the Object from memory, but merely deletes the reference to it. The memory management is automatic; you have no real control in Flash.


Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top