Jump to content
Search Community

Does height change in LoaderMax?

Zync test
Moderator Tag

Recommended Posts

I got a weird error happening and I'm not sure if its my code or loadermax and the height of my objects.

When i trace the height in the first loop on showThumbs() I'm getting 120 as the variable I set.

But when i trace it in my second loop on thumbsLoaded, for the first 4 images I'm getting a height of 120 but then the next ones are 156.8. Maybe I botched something with my position code somewhere but shouldn't the height of each contentDisplay stay the same?



	private function showThumbs():void 
		var lmThumbs:LoaderMax = new LoaderMax( { name:"thumbLoader" } );
		lmThumbs.addEventListener(LoaderEvent.COMPLETE, thumbsLoaded);

		var nImgWidth:Number = 210;
		var nImgHeight:Number = 120;
		var nMaxCols:Number = 4;
		var nSpacing:Number = 19;

		for (var i:int = 0; i < xList.length(); i++) 
			var iLoad:ImageLoader = new ImageLoader(xList[i].@img, new ImageLoaderVars()
			.x((i % nMaxCols) * (nImgWidth + nSpacing))
			.y(int(i / nMaxCols) * (nImgHeight + nSpacing))
			.prop("title", xList[i].@title)

			trace(int(i / nMaxCols) * (nImgHeight + nSpacing))
			trace("height "+nImgHeight)



	private function thumbsLoaded(e:LoaderEvent):void 

		//Loop through attach event listeners and text fields with title
		for (var i:int = 0; i < xList.length(); i++) 

			var cdImg:ContentDisplay = LoaderMax.getContent(xList[i].@name)
			var vars:Object = ImageLoader(cdImg.loader).vars;

			var txTitle:TextField = new TextField();
			//txTitle.text = vars.title;
			txTitle.text = vars.title
			txTitle.height = 20;
			trace("height now " +cdImg.height);

			txTitle.y = 120


Link to comment
Share on other sites

Nope, I'm pretty sure you didn't botch anything and it's not a problem with LoaderMax either. It simply has to do with the fact that you're using a scaleMode of "proportionalOutside" and you set crop to true, so imagine a very TALL image loading in there; It would get scaled so that the top and bottom extend past the 120 height, right? And then it gets cropped. The cropping happens with a scrollRect inside the ContentDisplay, so technically the extra content is still there, but it's getting chopped by the scrollRect. Visually everything is dandy, but Flash reports width/height values as though it completely ignores masks and scrollRects. So I bet your 5th image is taller than the others, right? So it's spilling over the top/bottom. Again, this isn't necessarily a problem or bug - it's just how Flash reports width/height values.


Does that clear things up?

Link to comment
Share on other sites

Actually all 6 images are the same image, landscape, so kinda weird it would be doing that for the 2nd line when its the same image.

I might just make the width and height class members and use that for exact values. Cheers for the help.

Link to comment
Share on other sites

  • 2 weeks later...

I think that my "flash banner" problem has the same issue, just for swfs (viewtopic.php?f=6&t=4196) and because of the wrong height sets the scrollrect etc. wrong thus causing the weird banners.


rawcontent.height (eg 116.65 instead of 100) is off for swfs. images and videos have the correct values though.


also happens with crop = false and any scalemode.


dont want to post an example here, where can I send you the url to?

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