Jump to content
Search Community

Accessing Variables/Properties on the Display Object

bensbury test
Moderator Tag

Recommended Posts

Hi,

 

There is probably a simple way to do this, but I didn't really know what to search for.

 

Basically I want to attach some property or variable to the contentDisplay object from the imageLoader so I can grab it from the rollOver/Out etc Events.

 

In the simplest case I am trying to pass an ID to the image loaded to it, so it can be linked to another loaded thumbnail image.

I have passed Vars about using the Params variable on the Loader but I can't access this from the event.target on the Rollover as it targets the displayObject.

 

Sorry if this isn't very clear..... but basically I would like to pass a variable to the image which I can pick up directly from a mouse Event using event.target.

 

Is this doable?

Link to comment
Share on other sites

Sorry, I figured it out so I'll answer my own question if some one else has a similar question.

 

You can add anything you like to the parameters property when creating the loader: (which I knew how to do)

 

thumbqueue.append( new ImageLoader(url + thumbList[i], {parameters: ['smith'], x:i*51, container:menu.thumbs, width:50, height:50, hAlign:"center", vAlign :"bottom", name:imgName,alpha:1, visible:true }) );

 

You can access this from the Loader... as so

 

private function onInitiate(e:LoaderEvent):void {
   		var preloader = e.target.vars.parameters;
	}

 

.... my problem was trying to access the parameters variable from a MouseEvent, but actually it was very easy:

 

private function thumbOver(e:MouseEvent):void {

		var i = e.target;
		trace(i.loader.vars.parameters);}

 

Just access the loader from the MouseEvent and there it is!

 

I hope this is a decent way of doing it, and also it might save some time for someone else.

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