Hi!
I have the same problem with URLLoader class.
I use it that way:
var request:URLRequest = new URLRequest("
http://localhost/kinoflex.php");var loader:URLLoader = new URLLoader();
public function send(datasend:String):void {
request.contentType = "text/xml";
request.method = URLRequestMethod.POST;
try {
request.data = datasend;
loader.load(request);
} catch (error:ArgumentError) {
Alert.show('An ArgumentError has occurred.','Error!');
} catch (error:SecurityError) {
Alert.show('A SecurityError has occurred.','Error!');
}
}
public function onInit():void {
loader.addEventListener('complete',receive);
}
public function receive(evtObj:Event):void {
var resXML:XML;
trace('Data format: '+loader.dataFormat);
trace('Bytes loaded: '+loader.bytesLoaded);
trace('Bytes total: '+loader.bytesTotal);
trace(loader.data);
resXML = XML(loader.data); // Error occures here
...
}
And the traces (repeating items skipped, xml formatted for
convenience):
Data format: text
Bytes loaded: 7713
Bytes total: 7713
<resp>
<cmd>get_libs</cmd>
<res>ok</res>
<movie>
<item><id>285</id><name>Адреналин</name><lid>976</lid></item>
[REPEATING_ITEMS]
<item><id>439</id><name>Прощальный
поцелуй</
TypeError: Error #1088: The markup in the document following the
root element must be well-formed.
at
kinoadmin/receive()[C:\pers\projects\flex\kinoadmin\kinoadmin.mxml:459]
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
flash.net::URLLoader/flash.net:URLLoader::onComplete()name><lid>1688</lid></item>
<item><id>434</id><name>Свидание
моей
мечты</name><lid>1696</lid></item>
[REPEATING_ITEMS]
<item><id>433</id><name>Эскадрилья
Лафайет</name><lid>1692</lid></item>
</movie>
</resp>яяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяя`
As we can see, the error goes before the trace outputs all
the text. May be function XML(loader.data) starts before all the
response passed to loader.data? And strange symbols attached to the
end of file. Every time they are different. I have no such strings
in my script. I've tested the response of my script, addresing it
directly in firefox - the script returns valid XML without any
trailing wierd symbols.
The size of received file is 7 714 bytes. And in this case
error came on 7092 bytes.
I will be glad if u find my mistake or solution of this
problem.
Thanks!