Hi I am loading images and data into flash via XML. Some bits of data are missing an image or just don't have one for various reasons. When the image URL is null flash returns the message TypeError: Error #2007: Parameter url must be non-null. I have been trying to catch this error using IO error event but I am unsure if this is the the correct method for doing this as I can't seem to get it working. This is causing a problem for me because when I add the items to the stage the data doesn't match the images and what I would like to do once I am able to capture this error is push a default image into the _trackArray which i will then use to add items to the stage.
private function callTracks(): void {
for (var i:Number = 0; i < _tracksTotal; i++){
var _trackpicUrl = _trackImage[i];
//trace(_trackImage[i]);
var _trackpicLoader = new Loader();
_trackpicLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, trackpicLoaded);
_trackpicLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
_trackpicLoader.load(new URLRequest(_trackpicUrl));
_trackpicLoader.name = i+1;
_trackArray.push(_trackpicLoader);
_containerMc.addChildAt(_trackpicLoader, _ringCounter);
}
}
private function loadError(e:IOErrorEvent): void {
trace("IO Error: " + e);
}
So why not just test if the value is null when you assign to _trackpicUrl
?
var _trackpicUrl:String;
if(_trackImage[i] == null) {
//do whatever you need to handle the null
_trackImage[i] = "myDefault.url";
}
_trackpicUrl = _trackImage[i];