Jump to content
Search Community

XMLLoader & ImageLoader Problem

thelbc test
Moderator Tag

Recommended Posts

Hi there,

 

I have a problem when using ImageLoader with a XML file.

 

The XML :

 

<?xml version="1.0" encoding="iso-8859-1"?> 








 

My As3 code :

 

var loader:XMLLoader = new XMLLoader("data.xml", {name:"xmlDoc", onComplete:completeHandler});

function completeHandler(event:LoaderEvent):void {
trace("load complete. XML content: " + LoaderMax.getContent("xmlDoc"));

var myText:String = LoaderMax.getContent("text001");
trace("This is myText" + myText);

var image:ContentDisplay = LoaderMax.getContent("image001");
addChild(image);


}

loader.load();

 

The trace statement on the variable myText works but I got an error #2007: Parameter child must be non-null. at flash.display::DisplayObjectContainer/addChild()

 

Like if my image ContentDisplay was empty.

 

What am I missing?

 

Thanks in advance,

 

 

J.

Link to comment
Share on other sites

I bet you just forgot to activate the ImageLoader and DataLoader classes. You need to do this so that XMLLoader can recognize them:

 

import com.greensock.loading.*;
LoaderMax.activate([imageLoader, DataLoader]);

 

And by the way, there's no purpose in having requireWithRoot="this.root" in your XML because this.root doesn't refer to anything - it's just a String. If you want the loader to be required, set that on the XMLLoader that is bringing in that XML.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...