Jump to content
GreenSock

DOURADO

XML error

Recommended Posts

Hola Jack,

First congratulations for the amazing work and thanks for the effort.

I'm having some issues with XML. I have been using bulkloader for my major project's and I have Class that manage all my load needs.

Since you release the LoaderMax I made necessary changes to work with it, so far so good, the class seems to be working ok.

 

The problem that I'm having is when a try to read a node from an XML and put it's content, in this case a text, inside a textField.

 

 

So in this class I read an XML and than I read the content that I want of some of those nodes.

Example(resume):

 

static private var xml:XML;

 

loader = new LoaderMax({name:"mainQueue", onProgress:progressHandler, autoDispose:true, noCache:true, onComplete:allPreContentLoaded});

 

loader.append(new XMLLoader(myXmlFile, {name:"primaryXml", integrateProgress:false}) );

 

static private function allPreContentLoaded(event:LoaderEvent):void

{

xml = new XML(LoaderMax.getContent("primaryXml"))

 

XML.ignoreWhitespace = false;

XML.ignoreComments = true;

XML.ignoreProcessingInstructions = true;

xml.toString();

 

// than a call for a method of one of my classes where a pass the xml

Main.myClass.addContent(xml);

}

 

 

//Once in my Class:

//"containerSWF" it's a swf that was loaded that has my text field myTitle.

 

public function addContent(theXML:XMl):void

{

trace("theXML.topContent.titulo: "+theXML.topContent.titulo) //the trace goes well and shows the text of "titulo"..

// the error comes when I do this

containerSWF.myTitle.text = theXML.topContent.titulo;

}

 

error:

ReferenceError: Error #1069: Property titulo not found on com.greensock.loading.display.ContentDisplay and there is no default value.

 

// end..

 

 

I did also:

var tempText:String = String(theXML.topContent.titulo)

containerSWF.myTitle.text = tempText;

I try to pass the "titulo" over a string even so I still have the error.

 

 

 

//the XML:

<?xml version="1.0" encoding="UTF-8"?>

 

 

Álbum de fotos

 

 

 

 

 

Regards,

Dourado.

Link to comment
Share on other sites

Hmm, I think there's something else going on - the info you posted doesn't seem to match properly. The error indicates that you're referencing the content of either a SWFLoader, an ImageLoader, or a VideoLoader, NOT an XMLLoader. And if the trace() worked fine, there's no way that setting a TextField's "text" property to that same value would generate the error you said. So could you please post an example FLA that demonstrates the issue? Again, I'm 99.9% sure there's something else going on in your code that isn't in what you posted.

Link to comment
Share on other sites

I know it sounds quite strange... specially because the trace goes well and xml has nothing to do with ContentDisplay...

But it's also strange that width the bulkloader versión I had no problem.. :( and I have been working with it for a while.

I'm sure that maybe it's something missing..I will send you the code and try to reach you by email.

Thanks for the time!

Link to comment
Share on other sites

After you sent me your files, I was able to see the problem: Your code is referencing the “content” of the loaders which is always a ContentDisplay object instead of the rawContent which is the actual raw content (in your case the swf that’s loaded). Let me explain…

 

It is extremely common for developers to want to work with a DisplayObject BEFORE the actual content is fully loaded, just like Adobe's Loader class. For example, maybe you create 20 thumbnail loaders and you want to size them in a certain way and position them on the screen while they’re loading (or before they even start loading). That’s why SWFLoader, ImageLoader, and VideoLoader all create a ContentDisplay object (just a fancy Sprite) immediately into which the raw content will load. It’s like a wrapper. So your loader's “content” refers to that ContentDisplay Sprite. Put that wherever you want. But if you want to refer to the raw content, like the actual swf file that is loaded with SWFLoader, you should reference the rawContent property of the loader (or the ContentDisplay – both have a “rawContent” property).

 

Your code was trying to reference stuff in the ContentDisplay wrapper instead of the raw swf that was loaded (rawContent). The solution is very easy: reference the rawContent instead of the content.

 

Example from your code:

BAD: tempFiles.push(LoaderMax.getContent(allObjects[kk][1]+tt));

GOOD: tempFiles.push(LoaderMax.getContent(allObjects[kk][1]+tt).rawContent);

 

Once I fixed that in your code, things seemed to work just fine.

 

Also, I noticed you’re using an outdated version of LoaderMax – I’d recommend getting the latest update at http://www.LoaderMax.com

 

Hope that helps.

Link to comment
Share on other sites

Hola Jack,

 

mmm... I thought that somehow you were creating a sprite or even an array of raw loaded content...

Ok so I use "LoaderMax.getContent(allObjects[kk][1]+tt).rawContent" to get the swf/bmp/video...

But in case of the XML, do I also use the node that I want like "node.rawContent" to reach his string?

Or by doing this would be ok

xml = new XML(LoaderMax.getContent("primaryXml").rawContent) //?

It's possible to activate or deactivate this in a way to reach always the rawContent.

 

Thank you a lot for such fast answer!

Regards.

 

Jorge.

Link to comment
Share on other sites

Nope, rawContent only applies to DisplayObject-related loaders like SWFLoader, ImageLoader, and VideoLoader. No need to do rawContent with XMLLoaders.

Link to comment
Share on other sites

Nope, rawContent only applies to DisplayObject-related loaders like SWFLoader, ImageLoader, and VideoLoader. No need to do rawContent with XMLLoaders.

 

Hola Jack,

 

I'm at home so I right now I can't test anything but it would be great if we could deactivate the raw property and work straight with raw content.

I think it would be best if those contents aren't in the flash display list. Otherwise we are creating in some cases to many sprites that could be avoided. As a result we are using more memory.

 

An other case If we want to clone bitmap's for any reason, once we have different classes and objects with bmp's I think it would help to improve the workflow if we don't have to look always for the rawContent.

 

Even so great work with LoaderMax is so as3 tasty as TweenLite. :)

Gracias!

Link to comment
Share on other sites

Actually, we covered this fairly early on in the beta phase of LoaderMax. I originally had the "content" property always spitting back what is now called rawContent but there are a lot of problems with that model which we discovered. For example, it is EXTREMELY common for developers to want to put things in the display list BEFORE the content has loaded. This would be impossible if things were based on rawContent for obvious reasons. Kinda like Adobe's Loader object - it's a DisplayObject that can be placed wherever you want even before you load() anything. LoaderMax's ContentDisplay goes one step further and allows you to even define a width/height and it draws a rectangle for you so that all interactive events (like rollovers/outs) function even before content has loaded. And then it can scale the rawContent to fit in that area using various scaleModes.

 

When designing the LoaderMax system, I had to consider common use cases and try to build things to serve the most customers the best way possible. I firmly believe that the ContentDisplay functionality makes the most sense even though there may be cases where you don't make use of the ContentDisplay object itself. In those rare situations, it does technically waste a very small amount of memory but if that causes problems in your application, you probably have bigger problems (architecture). And remember, it's easy to dispose() a loader or set autoDispose to true so that once it's loaded, the loader is instantly made eligible for garbage collection including that ContentDisplay (unless you used it of course).

 

I'm a BIG efficiency guy, so believe me when I tell you that I'm mindful of wasted resources. But again, you must step back and consider the whole system and common use cases. There are always trade offs with any decision. If I didn't create a ContentDisplay object, it'd save a VERY small amount of memory but it would sacrifice significant functionality that frankly I think FAR outweighs the small memory cost. Really, try using LoaderMax for a while with the ContentDisplay stuff and I think you'll quickly see why it's very valuable. For guys who are used to kludging along with Adobe's Loader class or one of the other batch loading tools out there, it requires a shift in mindset a bit, but once you "get it", I really think you'll enjoy the freedom and flexibility LoaderMax offers.

 

Is there some reason you think that using the rawContent property is very inconvenient? It seems very straightforward to me, but then again I'm totally biased and may be missing some important considerations.

Link to comment
Share on other sites

Hey Jack,

 

I wans't at any moment try to say that I was right or try to prove wherever.

I think you are one of the best programmers in the world! You optimize a lot and you are always pushing to give the best way possible! So I know that you would forget memory issues or performance.

You are right common for developers put their stuff in a sprite before they start the app, I do that :oops: . And yeah we can dispose() it...

I didn't know that you did first model with it. I'm sure that you are further away in testing the loader and in such small cases that we want to clone you are right it's just fine using the rawContent.

 

One more time, thank you a lot!!

Link to comment
Share on other sites

No problem at all. I hope you didn't get the impression that your questions offended me or something. I appreciate all the feedback and suggestions I get from other developers like you, so don’t hesitate to share or ask questions.

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.
×