AS3 image gallery grid scroillbar

For the following link (http://www.frcdstest.org/mdi/test4/frcd.html) the code below works perfect except I want to dynamically decide if the scrollbar needs to appear or not.

If the user uses 8 or less images, no scrollbar is needed. If there are more, it needs to be shown. I have a movieClip that has a tinted movieClip inside. When I make the height 1000, then the scrollbars appear. When I make it 100, they do not. This is fine, but I want to make the height change dynamically. I have a function at the bottom called "determineHeightOfBkgd". this updates the tinted movieClip size, dynamically, but somehow the movieClip whose height changes doesn't afffect the scrollbars. If I set the tinted movieClip height to 1000 and the publich, the scrollbars still think the height of the movieCLip hasn't changed, even though I dynamically changed the height.

Am I missing a step or is there a function that will force the stage to update? Using updateAfterEvent?It is either wrong or I am not using it correctly.
import fl.containers.UILoader;
import caurina.transitions.*;

//---------loading the external xml file-------
var urlRequest:URLRequest = new URLRequest("pics.xml");
var urlLoader:URLLoader = new URLLoader();
var myXML:XML = new XML();
var xmlList:XMLList;
myXML.ignoreWhitespace = true;
urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
urlLoader.load(urlRequest);
//--------holds the paths to the thumbnails-------
var arrayURL:Array = new Array();
//--------holds the paths to the big photos-------
var arrayName:Array = new Array();
//--------holds the thumbnail objects-------
var holderArray:Array = new Array();
//--------represents the number of columns-------
var nrColumns:uint = 4;// 5
//-------represents the container of our gallery
var sprite:Sprite = new Sprite();
addChild(sprite);
var thumb:Thumbnail;
//-------- the thumbnails container-------
var thumbsHolder:Sprite = new Sprite();
sprite.addChild(thumbsHolder);
//-------- the photoLoader container-------
var loaderHolder:Sprite = new Sprite();
loaderHolder.graphics.beginFill(0xffffff,1);
loaderHolder.graphics.drawRect(0,0,350,230);//loaderHolder.graphics.drawRect(0,0,550,330);
loaderHolder.graphics.endFill();
loaderHolder.x = 1000;// this needs to be way off the stage, thus the 1000 location
loaderHolder.y = 10;
sprite.addChild(loaderHolder);
//-------- loads the big photo-------
var photoLoader:UILoader = new UILoader();
photoLoader.width = 340;// 540
photoLoader.height = 220;// 320
photoLoader.y = 0;//5
photoLoader.x = 0;//5
photoLoader.buttonMode = true;
photoLoader.addEventListener(MouseEvent.CLICK,onClickBack);
loaderHolder.addChild(photoLoader);
//-------- static vars-------
var thumbHeight:uint = 110;

//-------- loads the big photo-------
/* we loop through the xml file
populate the arrayURL, arrayName and position the thumbnails*/
function fileLoaded(event:Event):void {
	myXML = XML(event.target.data);
	xmlList = myXML.children();
	var myBkgdHeight:uint = determineHeightOfBkgd();
	trace("myBkgdHeight: " + myBkgdHeight);

	bkgdTint.height = myBkgdHeight;

	for (var i:int=0; i<xmlList.length(); i++) {
		var picURL:String = xmlList[i].url;
		var picName:String = xmlList[i].big_url;
		arrayURL.push(picURL);
		arrayName.push(picName);
		holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
		holderArray[i].addEventListener(MouseEvent.CLICK,onClick);
		holderArray[i].name = arrayName[i];
		holderArray[i].buttonMode = true;
		if (i<nrColumns) {
			holderArray[i].y = 65;
			holderArray[i].x = i*thumbHeight+65;
		} else {
			holderArray[i].y = holderArray[i-nrColumns].y+thumbHeight;
			holderArray[i].x = holderArray[i-nrColumns].x;
		}
		thumbsHolder.addChild(holderArray[i]);
	}
}
//----handles the Click event added to the thumbnails--
function onClick(event:MouseEvent):void {
	photoLoader.source = event.currentTarget.name;
	Tweener.addTween(thumbsHolder, {x:-650, time:1, transition:"easeInElastic"});
	Tweener.addTween(loaderHolder, {x:10, time:1, transition:"easeInElastic"});
	Tweener.addTween(thumbsHolder, {alpha:0, time:1, transition:"linear"});
	Tweener.addTween(loaderHolder, {alpha:1, time:1, transition:"linear"});
}
//----handles the Click event added to the photoLoader----
function onClickBack(event:MouseEvent):void {
	Tweener.addTween(thumbsHolder, {x:0, time:1, transition:"easeInElastic"});
	Tweener.addTween(loaderHolder, {x:1000, time:1, transition:"easeInElastic"});
	Tweener.addTween(thumbsHolder, {alpha:1, time:2, transition:"linear"});
	Tweener.addTween(loaderHolder, {alpha:0, time:2, transition:"linear"});
}
//
function determineHeightOfBkgd():uint {
	trace("xmlList.length: " + xmlList.length());
	trace("height: " + bkgdTint.height);
	var myHeight:uint;
	myHeight = ((xmlList.length()/4) * thumbHeight);
	return myHeight;
}

Open in new window

msukowAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IqAndreasCommented:
Try changing this line:
myHeight = ((xmlList.length()/4) * thumbHeight);

To this:
myHeight = (int(xmlList.length/4) * thumbHeight);

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.