Share Posted February 21, 2011 hello i tried to pass custom parameters when an image is loaded with the imageLoader Class. it's possible to do that with onCompleteParams like i do it with TweenMax? thx! Link to comment Share on other sites More sharing options...
Share Posted February 22, 2011 Hey ya mate, I don't know if the official docs have been updated but you can add properties to your imageLoader objects by using the prop attribute: var iLoad:ImageLoader = new ImageLoader("myImage", new ImageLoaderVars() .name(xImgList.@name) .prop("prop1", "Hello") ) Then you can access those params on a click or complete event like so: var vars:Object = ImageLoader(e.currentTarget.loader).vars trace(vars.prop1); Link to comment Share on other sites More sharing options...
Share Posted February 22, 2011 Yep, Zync is exactly correct. And to answer your specific question, no there is no such thing as onCompleteParams in LoaderMax because everything is event-based rather than callback-based. There are some rather compelling reasons why this is a better approach for a loading system like this, but callbacks are better suited for tweening which is why I used them accordingly. You can store whatever you want in the "vars" object that you pass into the loader. So, for example: var loader:ImageLoader = new ImageLoader("1.jpg", {myCustomData1:"whatever", myFunkyVariable:"yesThisWorks", onComplete:test}); loader.load(); function test(event:LoaderEvent):void { trace(event.target + " completed, myCustomData1 is " + event.target.vars.myCustomData1 + ", and myFunkyVariable is " + event.target.vars.myFunkyVariable); } 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