Jump to content
Search Community

Passing through vars with a loadermax

andyUK test
Moderator Tag

Recommended Posts

Hi

 

Is there a way to pass through a custom var with a loadermax instance other then the name.

 

I'm making a tabbed menu with thumbnails.

 

So i have 3 main tabs. And each tab has varied amount of sub-tabs. The sub-tabs relate to 6 thumbs each with in them.

 

I want to pass through what tab number the sub-tabs should be added to.

 

I hope that makes sense.

 

I just want to pass through a int var.

Link to comment
Share on other sites

I'm not sure I understand the question, but you can pass pretty much any data into the vars object. For example:

 

var loader:ImageLoader = new ImageLoader("1.jpg", {name:"image1", myCustomData:"whatever", onComplete:completeHandler});
loader.load();

function completeHandler(event:LoaderEvent):void {
   trace("myCustomData: " + event.target.vars.myCustomData);
}

 

So you can look it up via the vars property (which is just a generic object). Make sense?

Link to comment
Share on other sites

if you do it with the XML loader, you can 0pass custom content in through the xml as the xmlloader just filters through the image loaders. I don't have an example for you but look at the XMLLoader examples, and the flash xml structure documentation. They can be used together

Link to comment
Share on other sites

  • 8 months later...
Guest bcournoyer

When I try this I get:

 

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

 

var image:ImageLoader = new ImageLoader(imgNavURL, {container:this, 
												 width:272, height:170, 
												 scaleMode:"proportionalInside", 
												 centerRegistration:true, id:thumbid});
...

function thumbHover(e:Event):void{
trace ("id: " + e.target.vars.id); (error on this line)

...

Link to comment
Share on other sites

vars is a property of the ImageLoader not the ContentDisplay object.

 

in the examples above e.target.vars is located in an eventhandler for a LoaderEvent.

 

function completeHandler(event:LoaderEvent):void {

trace("myCustomData: " + event.target.vars.myCustomData);

}

 

your example is using a generic Event (which i'm assuming is a MouseEvent as your function is called thumbHover) in which case the target of the event is the ContentDisplay.

 

fortunately, the ContentDisplay object has a loader property which refers to the loader that it is associated with it. http://www.greensock.com/as/docs/tween/ ... tml#loader

 

so you could use:

 

trace ("id: " + e.target.loader.vars.id);

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