Loading Variables in Flash 9
In Flash 9 the URLLoader loads the raw data and stores them as they are in the data variable. The
URLVariable class is used to parse the received raw value and to transform it in a set of key - value pairs.
Chapter 12: Building Interactive Content with Flash
327
import flash.Lib;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.events.Event;
class Main
{
public static function main()
{
var loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function(event : Event)
{
var vars = new URLVariables(loader.data);
trace(vars.message);
trace(vars.to);
});
loader.load(new URLRequest(???variables.txt???));
}
}
Loading XML
The same techniques described previously to load variable values can be used to load an XML
document. The response is treated as a whole and converted in an XML object using the Xml.parse()
method.
Loading XML with Flash 6 to 8
To receive the result in its raw format, it is preferable to use the onData event that passes as an argument
the unmodified result of the communication with the server.
Pages:
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640