djliquidice
08-15-2006, 03:15 PM
OK, so i downloaded the whole flexbuilder2 + sdk. I'm getting errors "Access of undfined property "request, loader and dataXML". This is pissing me off. This is coming right out of the programming_as3.pdf file (pg 367). I included a bunch of shyte to see if i was forgetting something.
import mx.controls.*;
import mx.rpc.http.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.*;
import flash.xml.*;
import flash.events.*;
import flash.errors.*;
var secondsUTC:Number = new Date().time;
var dataXML:XML = <login><time>{secondsUTC}</time><username>Ernie</username><password>guru</password></login>;
var request:URLRequest = new URLRequest("http://www.yourdomain.com/login.cfm");
request.contentType = "text/xml";
request.data = dataXML.toXMLString();
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
try {
loader.load(request);
} catch (error:ArgumentError) {
trace("An ArgumentError has occurred.");
} catch (error:SecurityError) {
trace("A SecurityError has occurred.");
}
The previous snippet creates an XML instance named dataXml that contains an XML packet
to be sent to the server. Next, you set the URLRequest contentType property to "text/xml"
and set the URLRequest data property to the contents of the XML packet, which are
converted to a string by using the XML.toXMLString() method. Finally, you create a new
URLLoader instance and send the request to the remote script by using the
URLLoader.load() method.
import mx.controls.*;
import mx.rpc.http.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.*;
import flash.xml.*;
import flash.events.*;
import flash.errors.*;
var secondsUTC:Number = new Date().time;
var dataXML:XML = <login><time>{secondsUTC}</time><username>Ernie</username><password>guru</password></login>;
var request:URLRequest = new URLRequest("http://www.yourdomain.com/login.cfm");
request.contentType = "text/xml";
request.data = dataXML.toXMLString();
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
try {
loader.load(request);
} catch (error:ArgumentError) {
trace("An ArgumentError has occurred.");
} catch (error:SecurityError) {
trace("A SecurityError has occurred.");
}
The previous snippet creates an XML instance named dataXml that contains an XML packet
to be sent to the server. Next, you set the URLRequest contentType property to "text/xml"
and set the URLRequest data property to the contents of the XML packet, which are
converted to a string by using the XML.toXMLString() method. Finally, you create a new
URLLoader instance and send the request to the remote script by using the
URLLoader.load() method.