Jump to content
Search Community

ImageLoaders and swfloaders in xml

mindspaced test
Moderator Tag

Recommended Posts

Hi Jack and others,

 

I'm trying hard to wrap my head around this whole package, but for some reason, it's just not clicking for me yet. What I'm trying to do should be simple, but it stumps me.

 

I dramatically simplified your sample files, thinking that there may be others in my position who are trying to get a handle on all this. I'm trying to load both images and swfs, based on results from an xml file. Basically, all items will have images, and some will also have swfs. I simply want the LoaderMax to find the swf node and load it if present.

 

sample code here:

private function _xmlCompleteHandler(event:Event):void {			
		var _item:LoaderMaxTestItem, thumbnail:DisplayObject, swf:DisplayObject;
		var items:XMLList = (_xmlLoader.content as XML).item; //could also do LoaderMax.getContent("sites").site
		for each (var item:XML in items) {
			thumbnail = LoaderMax.getContent(item.@name + "Image");
			if (thumbnail != null) {
				_item = new LoaderMaxTestItem(item.@name, item.@title, thumbnail);
				_items.push(_item);
			}
			swf = LoaderMax.getContent(item.@name + "SWF");
			if (swf != null) {
				trace("success");
				//still to create the TestItem swf here, if successful
			}
		}
		//loop through the items and position them in 5 columns on the screen
		for (var i:int = 0; i < _items.length; i++) {
			_item = _items[i];
			this.addChild(_item);
			_item.width = 100;
			_item.height = 100;
			_item.x = (i % 2) * _item.width + 25;
			_item.y = int(i / 2) * _item.height + 54;
		}

		//retreive the "imagesLoader" LoaderMax instance that was dynamically created by parsing the XML file.
		_imagesLoader = LoaderMax.getLoader("imagesLoader") as LoaderMax;
	}

I think I'll be using LoaderMax in many, if not most, future projects. Therefore, more sample files that illustrate the various ways it can be used would be great, if/when you have time to create them.

 

Thanks!

Link to comment
Share on other sites

Ok. Simple enough.

 

There were two issues:

1) I needed to move the SWFLoader node up into the loadermax node, rather than two separate loadermax nodes.

2) I needed to active the SWFLoader plugin - LoaderMax.activate([imageLoader,SWFLoader]);

 

Sorry for the obvious. My hopes for further samples still stands.

 

Thanks!

Link to comment
Share on other sites

Using the posted code from above, and after making the corrections, how would I access the url of the current loadermax item?

 

I use the folloiwng line of code to get the image displayObject: image = LoaderMax.getContent(item.@name + "Image");

 

But how do I figure out its url?

 

Thanks!

Link to comment
Share on other sites

Thanks, BTW, I've been a bit hampered by the fact that clicking on the "Show Inherited Public Properties" of your documentation fails in Chrome (5.0.375.86). Nothing happens when I click. I knew that I had seen that inherited parameter last week, but couldn't find it today. Might want to take a look at your js there.

 

Also, on a side note, there is a broken link on the loadermax page (http://www.greensock.com/loadermax/), where it says "See XMLLoader's ASDocs for details."

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