Share Posted September 27, 2010 Hello, I am loading images for a gallery, and I need them to have a predefined background. So I set the parameters height and width in the vars variable. I am also using the container parameter to add the pictures straight to the container. However when the ContentDisplayObject is being added to the container the object width and height report 0. Do you know what might cause the problem? Thank you Link to comment Share on other sites More sharing options...
Share Posted September 27, 2010 Are you sure? I just tested this: var l:ImageLoader = new ImageLoader("assets/1.jpg", {container:this, width:100, height:100}); l.load(); trace(l.content.width+", "+l.content.height); //traced "100, 100" If that's not working for you, please post an FLA that demonstrates the issue so we can just publish it and see exactly what's going on. Maybe you have some conflicting code in here? And you are using the latest version, right? http://www.LoaderMax.com Link to comment Share on other sites More sharing options...
Author Share Posted September 27, 2010 Hello, I am using FlashBuilder so I cannot make fla with that. It gives the same result for me as well. But it's during the initialisation of the ImageLoader. override public function addChild(child:DisplayObject):DisplayObject { trace(child.width) // give 0 with child being a ContentDisplayObject return _browser.addChild(child) } public function loadImage(file:FileData):void { var vars:ImageLoaderVars = new ImageLoaderVars; vars.autoDispose = false vars.bgColor = ColorLibrary.LIGHT_MIDGREY vars.bgAlpha = 1 vars.width = _pictureSize vars.height = _pictureSize vars.scaleMode = "proportionalInside" vars.name = file.name vars.context = NEditor.CONTEXT vars.container = this vars.smoothing = true var loader:ImageLoader = new ImageLoader(file.path,vars); trace(loader.content.width) // give same value as _pictureSize loader.load(); trace(loader.content.width) // give same value as _pictureSize } May be it's not a bug and a design decision. But I thought the point of giving it a size at the begining (especially when you give it a background color) was that the display object will right away size to the dimension that were given. No? Link to comment Share on other sites More sharing options...
Share Posted September 27, 2010 Oh, I see what you're saying. Yeah, ContentDisplay does apply the size right away - immediately after adding it to the container. I never really thought of a scenario where code would rely on the order of that being switched, but it does make sense to apply the size first and then add it to the container, so I just posted an update that does exactly that. Snag it at http://www.LoaderMax.com (or log into your GreenSock account if you're a club member) Link to comment Share on other sites More sharing options...
Author Share Posted September 28, 2010 Thanks that works great!!! 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