Share Posted November 23, 2013 Is there some simple way to add some vars to ImageLoader? I mean, like this: thumbLoader.append(new ImageLoader(thumbnail_images[i], {name:"photo"+i, container:this, lalala_var:i})); Link to comment Share on other sites More sharing options...
Share Posted November 24, 2013 G'day mate, You can add and access custom user properties using the following method: public function Main() { var il:ImageLoader = new ImageLoader("myImage.png",new ImageLoaderVars() .name("myImage") .container(stage) .onComplete(loadedImage) .prop("lalala", "myValue")); //Use the prop method of imageloader vars to add a property. name , value il.load() } private function loadedImage(e:LoaderEvent):void { var vars:Object = ImageLoader(e.currentTarget).vars; //access your custom variable name now trace(vars.lalala); } Or if you prefer a more inline approach instead of the ImageLoaderVars: public function Main() { //Or if you prefer inline var il:ImageLoader = new ImageLoader("myImage.png", { name:"myImage", container:stage, onComplete:loadedImage, lalala: "myValue2"} ); il.load() } private function loadedImage(e:LoaderEvent):void { var vars:Object = ImageLoader(e.currentTarget).vars; //access your custom variable name now trace(vars.lalala); //traces myValue2 } 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now