Dynamic Text Box Height

All,
I downloaded the following template: http://www.flashmo.com/preview/flashmo_232_spread_gallery

When you double click on the picture the photo descrpition box is the same and I’d like to make it dynamic. The movie clip that contains the text box is called “flashmo_pic_info” and the text box name is “photo_description”. How can make it so that the text box is the size of whatever is in photo_description? Here is the AS so you don’t have to download the template. Any help you could provide would be greatly appreciated. Thanks in advance. Here is the AS:

import caurina.transitions.*;
import flash.events.Event;
import flash.display.Shape;
import flash.display.MovieClip;

flashmo_graphic.visible = false;

var enable_fullscreen:Boolean = true;
var folder:String = "photos/";
var css_file:String = "flashmo_210_style.css";
var tween_duration:Number = 0.6;
var tn_border_size:Number = 5;
var tn_border_color:Number = 0xFFFFFF;
var photo_border_size:Number = 10;
var photo_border_color:Number = 0xFFFFFF;
var bar_status:uint = 0;

var pic_info_x:Number;
var pic_info_y:Number;
var previous_x:Number;
var previous_y:Number;
var next_x:Number;
var next_y:Number;
var close_x:Number;
var close_y:Number;

var progress_interval:uint;
var i:Number;
var tn:Number = 0;
var current_tn_x:Number;
var current_tn_y:Number;
var current_pic_no:Number = -1;
var next_pic_no:Number;
var total_items:Number;
var tn_loader:Loader = new Loader();
var pic_loader:Loader = new Loader();
var css_loader:URLLoader = new URLLoader();
var flashmo_style:StyleSheet = new StyleSheet();
var flashmo_xml:XML;
var flashmo_photo_list = new Array();
var photo_bm:Bitmap = new Bitmap();
var mc:MovieClip = new MovieClip();
var flashmo_pic:MovieClip = new MovieClip();
var flashmo_pic_border:Shape = new Shape();
var photo_property:MovieClip = new MovieClip();
var thumbnail_group:MovieClip = new MovieClip();
var timer_running:Boolean = false;

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener( Event.RESIZE, resize_listener );
set_this_xy();
	
flashmo_pic_info.visible = false;
flashmo_close.visible = false;
flashmo_previous.visible = false;
flashmo_next.visible = false;
flashmo_fullscreen.visible = false;
close_loading.visible = false;
loading_info_bg.visible = false;
loading_info.visible = false;
loading_info.text = "";
tn_loading_info.text = "Loading XML Data...";

photo_property.mask = flashmo_mask;

this.removeChild(flashmo_mask);
this.addChild(thumbnail_group);
this.addChild(loading_info_bg);
this.addChild(loading_info);
this.addChild(tn_loading_info);

function set_this_xy(): void
{
	this.x = Math.floor( stage.stageWidth * 0.5 );
	this.y = Math.floor( stage.stageHeight * 0.5 );
	flashmo_fullscreen.x = this.x - flashmo_fullscreen.width;
	flashmo_fullscreen.y = this.y - flashmo_fullscreen.height;
	tn_loading_info.x = - Math.floor( stage.stageWidth * 0.5 ) + 20;
	tn_loading_info.y = - Math.floor( stage.stageHeight * 0.5 ) + 20;
}

function resize_listener( e:Event ): void
{
	set_this_xy();
	
	if( !timer_running )
	{
		var timer:Timer = new Timer( 1000, 1 );
		timer.addEventListener( TimerEvent.TIMER, resize_timer );
		timer.start();
		timer_running = true;
	}
}
 
function resize_timer( e:TimerEvent ): void
{
	timer_running = false;
    set_tn_xy();
}

function set_tn_xy(): void
{
	for( i = 0; i < thumbnail_group.numChildren; i++ )
		randomize_tn( MovieClip( thumbnail_group.getChildAt( i ) ) );
}

function randomize_tn( each_mc:MovieClip ): void
{
	var random_x:Number = Math.floor( Math.random() * ( stage.stageWidth - each_mc.width ) - 
			   ( stage.stageWidth * 0.5 ) + each_mc.width * 0.5 );
	var random_y:Number = Math.floor( Math.random() * ( stage.stageHeight - each_mc.height ) - 
			   ( stage.stageHeight * 0.5 ) + each_mc.height * 0.5 );

	Tweener.addTween( each_mc, { x: random_x, y: random_y,
					  scaleX: 1, scaleY: 1,
					  alpha: 1, rotation: Math.random() * 90 - 45,
					  time: tween_duration * 1.5, delay: Math.random() * 1.0, transition: "easeInOutQuad" } );
}

function load_gallery(xml_file:String):void
{
	var xml_loader:URLLoader = new URLLoader();
	xml_loader.load( new URLRequest( xml_file ) );
	xml_loader.addEventListener( Event.COMPLETE, create_gallery );	
}

function create_gallery(e:Event):void
{
	flashmo_xml = new XML(e.target.data);
	total_items = flashmo_xml.photo.length();
	
	enable_fullscreen = flashmo_xml.config.@fullscreen_button.toString() == "false" ? false : true;
	
	if( flashmo_xml.config.@folder.toString() != "" )
		folder = flashmo_xml.config.@folder.toString();
	
	if( flashmo_xml.config.@css_file.toString() != "" )
		css_file = flashmo_xml.config.@css_file.toString();
		
	if( flashmo_xml.config.@tween_duration.toString() != "" )
		tween_duration = parseFloat( flashmo_xml.config.@tween_duration.toString());
	
	if( flashmo_xml.config.@thumbnail_border_size.toString() != "" )
		tn_border_size = parseInt( flashmo_xml.config.@thumbnail_border_size.toString());
	
	if( flashmo_xml.config.@thumbnail_border_color.toString() != "" )
		tn_border_color = flashmo_xml.config.@thumbnail_border_color.toString();
		
	if( flashmo_xml.config.@photo_border_size.toString() != "" )
		photo_border_size = parseInt( flashmo_xml.config.@photo_border_size.toString());
	
	if( flashmo_xml.config.@photo_border_color.toString() != "" )
		photo_border_color =  flashmo_xml.config.@photo_border_color.toString();
				
	if( enable_fullscreen )
	{
		flashmo_fullscreen.visible = true;
		flashmo_fullscreen.addEventListener( MouseEvent.CLICK, switch_screen_mode );
		this.addChild( flashmo_fullscreen );
	}
				
	for( i = 0; i < total_items; i++ )
	{
		flashmo_photo_list.push( {
			thumbnail: flashmo_xml.photo*.thumbnail.toString(), 
			filename: flashmo_xml.photo*.filename.toString(),
			description: flashmo_xml.photo*.description.toString()			
		} );
	}
	
	css_loader.load( new URLRequest(css_file) );
	css_loader.addEventListener(Event.COMPLETE, css_complete);
}

function switch_screen_mode( me:MouseEvent )
{			
	if( stage.displayState == StageDisplayState.NORMAL )
		stage.displayState = StageDisplayState.FULL_SCREEN;
	else
		stage.displayState = StageDisplayState.NORMAL;
}

function css_complete(e:Event):void 
{
	flashmo_style.parseCSS(css_loader.data);
	flashmo_pic_info.photo_description.styleSheet = flashmo_style;
	flashmo_pic_info.photo_description.embedFonts = false;
	load_tn();
}

function load_tn():void
{
	var tn_request:URLRequest = new URLRequest( folder + flashmo_photo_list[tn].thumbnail );
		
	tn_loader = new Loader();
	tn_loader.load(tn_request);
	tn_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, tn_progress);
	tn_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, tn_loaded);
	tn++;
}

function tn_progress(e:ProgressEvent):void
{	
	tn_loading_info.text = "Loading Thumbnail " + tn + " of " + total_items;
}

function tn_loaded(e:Event):void
{		
	if( tn < total_items )
		load_tn();
	else
	{	
		tn_loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, tn_progress);
		tn_loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, tn_loaded);
		tn_loader = null;
		tn_loading_info.text = "";
		tn_loading_info.visible = false;
	}
	
	var flashmo_tn_bm:Bitmap = new Bitmap();
	var flashmo_tn_mc:MovieClip = new MovieClip();
	
	flashmo_tn_bm = Bitmap(e.target.content);
	flashmo_tn_bm.smoothing = true;
	flashmo_tn_bm.x = - Math.floor( flashmo_tn_bm.width * 0.5 );
	flashmo_tn_bm.y = - Math.floor( flashmo_tn_bm.height * 0.5 );
	
	if( tn_border_size > 0 )
	{
		var bg_width:Number = flashmo_tn_bm.width + tn_border_size * 2;
		var bg_height:Number = flashmo_tn_bm.height + tn_border_size * 2;
			
		flashmo_tn_mc.graphics.beginFill(tn_border_color);
		flashmo_tn_mc.graphics.drawRect( - Math.floor( bg_width * 0.5 ), 
										 - Math.floor( bg_height * 0.5 ), 
										 bg_width, bg_height );
		flashmo_tn_mc.graphics.endFill();
	}
				
	flashmo_tn_mc.addChild( flashmo_tn_bm );
	flashmo_tn_mc.name = "flashmo_tn_" + thumbnail_group.numChildren;
	flashmo_tn_mc.buttonMode = true;
	flashmo_tn_mc.alpha = 0;

	flashmo_tn_mc.addEventListener( MouseEvent.MOUSE_DOWN, tn_down );
	flashmo_tn_mc.addEventListener( MouseEvent.MOUSE_UP, tn_up );
	
	randomize_tn( flashmo_tn_mc );
	thumbnail_group.addChild( flashmo_tn_mc );	
}

function tn_down(e:MouseEvent):void
{
	e.target.startDrag();
	
	mc = MovieClip(e.target);
	mc.addEventListener( MouseEvent.CLICK, tn_click );
	stage.addEventListener(MouseEvent.MOUSE_UP, stage_up );
	
	thumbnail_group.addChild( mc );
	current_tn_x = Math.floor( mc.x );
	current_tn_y = Math.floor( mc.y );
	
	Tweener.addTween( mc, { scaleX: 1.25, scaleY: 1.25, rotation: 0,
					 		time: tween_duration, transition: "easeIn" } );
}

function tn_up(e:MouseEvent):void
{
	mc = MovieClip(e.target);
	mc.stopDrag();
	stage.removeEventListener(MouseEvent.MOUSE_UP, stage_up );
	
	if( Math.floor( mc.x ) != current_tn_x || Math.floor( mc.y ) != current_tn_y )
		mc.removeEventListener( MouseEvent.CLICK, tn_click );
		
	Tweener.addTween( mc, { scaleX: 1, scaleY: 1, rotation: Math.random() * 90 - 45,
							time: tween_duration, transition: "easeOut", onComplete: register_click } );	
}

function stage_up( e:MouseEvent ):void
{
	mc.stopDrag();
	randomize_tn( mc );
}

function register_click():void
{
	mc.addEventListener( MouseEvent.CLICK, tn_click );
}

function tn_click(e:MouseEvent):void
{
	mc = MovieClip(e.target);
	next_pic_no = parseInt(mc.name.slice(11,15));
	Tweener.addTween( thumbnail_group, { alpha: 0.2, time: tween_duration, transition: "easeOut" } );
	thumbnail_group.mouseChildren = false;
	mc.removeEventListener( MouseEvent.CLICK, tn_click );
	load_photo();
}

function load_photo():void
{
	if( next_pic_no >= flashmo_photo_list.length )
		next_pic_no = 0;
	else if( next_pic_no < 0 )
		next_pic_no = flashmo_photo_list.length - 1;	
		
	close_loader();
	
	var pic_request:URLRequest = new URLRequest( folder + flashmo_photo_list[next_pic_no].filename );			
	pic_loader = new Loader();	
	pic_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_photo_loaded);
	pic_loader.load(pic_request);
	
	this.addChild( loading_info_bg );
	this.addChild( loading_info );
	this.addChild( close_loading );
				
	progress_interval = setInterval( add_progress_listener, 1000 );
}

function add_progress_listener()
{	
	try
	{
		pic_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, on_photo_progress);	
	}
	catch( e:Error ){}
}

function on_photo_progress(e:ProgressEvent):void
{	
	clearInterval( progress_interval );
	
	if( !loading_info_bg.visible )
	{					
		loading_info.text = "Loading Image...";
		loading_on( true );
	}
	var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);

	if( percent < 100 )
	{
		var filesize:Number = Math.round(e.bytesTotal / 1024);
		loading_info.text = "Loading Image " + ( next_pic_no + 1 ) + 
							"... " + percent + "% (" + filesize + "KB)";
		loading_info_bg.width = loading_info.width;	
	}
}

function on_close_load_click( me:MouseEvent ):void
{
	loading_on( false );
	close_loader();
	Tweener.addTween( thumbnail_group, { alpha: 1, time: tween_duration, transition: "easeOut" } );
	thumbnail_group.mouseChildren = true;
	next_pic_no = current_pic_no;
}

function on_photo_loaded(e:Event):void
{
	try
	{
		clearInterval( progress_interval );		
		loading_on( false );
		
		flashmo_fullscreen.mouseEnabled = false;
		flashmo_close.mouseEnabled = false;
		flashmo_pic.mouseEnabled = false;
				
		photo_bm = new Bitmap();
		photo_bm = Bitmap(e.target.content);
		photo_bm.smoothing = true;
				
		if( flashmo_pic.numChildren > 0 )
		{
			flashmo_pic_info.visible = flashmo_previous.visible = 
			flashmo_next.visible = flashmo_close.visible = false;
			
			Tweener.addTween( flashmo_pic, { alpha: 0, time: tween_duration, transition: "easeOut",
							 				 onComplete: remove_photo });
		}
		else
		{
			thumbnail_group.mouseChildren = false;
			thumbnail_group.alpha = 0.5;
			flashmo_pic.alpha = 0;
			add_photo( true );
		}
	}
	catch( e:Error ){ }
}

function loading_on( loading_visible:Boolean ):void
{
	if( loading_visible )
	{
		loading_info.visible = true;
		loading_info_bg.visible = true;
		close_loading.visible = true;
		close_loading.addEventListener( MouseEvent.CLICK, on_close_load_click );
	}
	else
	{
		loading_info.text = "";
		loading_info.visible = false;
		loading_info_bg.visible = false;
		close_loading.visible = false;
		close_loading.removeEventListener( MouseEvent.CLICK, on_close_load_click );
	}
}

function remove_photo(): void
{
	flashmo_pic.removeChildAt( 0 );
	add_photo( false );
}

function add_photo( first_time:Boolean ):void
{	
	var bg_width:Number = photo_bm.width + photo_border_size * 2;
	var bg_height:Number = photo_bm.height + photo_border_size * 2;
	
	photo_property.x = - Math.floor( photo_bm.width * 0.5 );
	photo_property.y = - Math.floor( photo_bm.height * 0.5 );
	
	if( first_time )
	{	
		flashmo_pic_border = new Shape();
		flashmo_pic_border.graphics.beginFill( photo_border_color );
		flashmo_pic_border.graphics.drawRect( 0, 0, bg_width, bg_height );
		flashmo_pic_border.graphics.endFill();
		this.addChild( flashmo_pic_border);		
		set_border_mask();
	}
	else
	{			
		if( flashmo_pic_border.width != bg_width || flashmo_pic_border.height != bg_height )
		{	
			Tweener.addTween( flashmo_pic_border, { x: photo_property.x - photo_border_size, 
							 						y: photo_property.y - photo_border_size, 
													width: bg_width, height: bg_height, 
													time: tween_duration, transition: "easeOut" });
			
			Tweener.addTween( flashmo_mask, { x: photo_property.x, y: photo_property.y, 
											  width: photo_bm.width, height: photo_bm.height, 
											  time: tween_duration, transition: "easeOut", onComplete: set_buttons });
		}
		else
			set_border_mask();
	}
}

function set_border_mask(): void
{
	flashmo_pic_border.x = photo_property.x - photo_border_size;
	flashmo_pic_border.y = photo_property.y - photo_border_size;
	flashmo_mask.x = photo_property.x;
	flashmo_mask.y = photo_property.y;
	flashmo_mask.width = photo_bm.width;
	flashmo_mask.height = photo_bm.height;
	set_buttons();
}

function set_buttons(): void
{			
	flashmo_pic.addChild( photo_bm );
	
	Tweener.addTween( flashmo_pic, { alpha: 1, time: tween_duration, transition: "easeOut",
					 				 onComplete: enable_buttons });
	
	flashmo_pic.doubleClickEnabled = true;
	flashmo_pic.addEventListener( MouseEvent.DOUBLE_CLICK, on_close_click );
	flashmo_pic.addEventListener( MouseEvent.CLICK, on_photo_click );
	flashmo_close.addEventListener( MouseEvent.CLICK, on_close_click );
	flashmo_previous.addEventListener( MouseEvent.CLICK, on_previous_click );
	flashmo_next.addEventListener( MouseEvent.CLICK, on_next_click );
	
	flashmo_pic_info.photo_info_bg.width = photo_bm.width;
	flashmo_pic_info.photo_description.width = photo_bm.width - ( flashmo_pic_info.photo_description.x * 2 );
	//flashmo_pic_info.photo_description.height = flashmo_pic_info.photo_description.y;
	flashmo_pic_info.photo_description.htmlText = flashmo_photo_list[next_pic_no].description;
	
	set_info_xy();
			
	flashmo_pic_info.x = pic_info_x;
	flashmo_pic_info.y = pic_info_y;
	flashmo_previous.x = previous_x;
	flashmo_previous.y = previous_y;
	flashmo_next.x = next_x;
	flashmo_next.y = previous_y;
	flashmo_close.x = close_x;
	flashmo_close.y = close_y;
				
	photo_property.addChild(flashmo_pic);
	photo_property.addChild(flashmo_pic_info);
	photo_property.addChild(flashmo_close);
	photo_property.addChild(flashmo_previous);
	photo_property.addChild(flashmo_next);
	
	flashmo_pic_info.visible = flashmo_previous.visible = 
	flashmo_next.visible = flashmo_close.visible = true;
	
	this.addChild( photo_property );
	this.addChild( flashmo_mask );
	
	flashmo_mask.x = photo_property.x;
	flashmo_mask.y = photo_property.y;
	flashmo_pic_border.x = photo_property.x - photo_border_size;
	flashmo_pic_border.y = photo_property.y - photo_border_size;
	
	pic_loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, on_photo_progress);
	pic_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, on_photo_loaded);
	pic_loader = null;
	
	current_pic_no = next_pic_no;
}

function enable_buttons(): void
{
	flashmo_fullscreen.mouseEnabled = true;
	flashmo_close.mouseEnabled = true;
	flashmo_pic.mouseEnabled = true;
}

function set_info_xy():void
{
	pic_info_x = flashmo_pic.x;
	previous_y = flashmo_pic.y + Math.floor(( flashmo_pic.height - flashmo_previous.height ) * 0.5 );
	next_y = previous_y;
	
	if( bar_status == 0 )
	{		
		pic_info_y = flashmo_pic.y + flashmo_pic.height;
		previous_x = flashmo_pic.x - flashmo_previous.width - 5;
		next_x = flashmo_pic.x + flashmo_pic.width + flashmo_next.width + 5;
		close_x = flashmo_pic.x + flashmo_pic.width + 5;
		close_y = flashmo_pic.y - flashmo_close.height - 5;
	}
	else
	{
		pic_info_y = flashmo_pic.y + flashmo_pic.height - flashmo_pic_info.height;
		previous_x = pic_info_x;		
		next_x =  flashmo_pic.x + flashmo_pic.width;
		close_x = flashmo_pic.x + flashmo_pic.width - flashmo_close.width;
		close_y = flashmo_pic.y;
	}
}

function on_photo_click(me:MouseEvent):void
{						
	bar_status++;

	if( bar_status > 1 )
		bar_status = 0;
	
	set_info_xy();		
	
	Tweener.addTween ( flashmo_pic_info, {	y: pic_info_y, 
						time: tween_duration, transition: "easeOutQuart" } );
	Tweener.addTween ( flashmo_previous, {	x: previous_x, 
						time: tween_duration, transition: "easeOutQuart" } );
	Tweener.addTween ( flashmo_next, {	x: next_x, 
						time: tween_duration, transition: "easeOutQuart" } );
	Tweener.addTween ( flashmo_close, {	x: close_x, y: close_y,
						time: tween_duration, transition: "easeOutQuart" } );
}

function on_close_click(me:MouseEvent):void
{
	close_loader();
	loading_on( false );
	
	flashmo_pic.removeEventListener( MouseEvent.DOUBLE_CLICK, on_close_click );
	flashmo_pic.removeEventListener( MouseEvent.CLICK, on_photo_click );
	flashmo_close.removeEventListener( MouseEvent.CLICK, on_close_click );
	flashmo_previous.removeEventListener( MouseEvent.CLICK, on_previous_click );
	flashmo_next.removeEventListener( MouseEvent.CLICK, on_next_click );
		
	photo_property.removeChild( flashmo_close );
	photo_property.removeChild( flashmo_previous );
	photo_property.removeChild( flashmo_next );
	photo_property.removeChild( flashmo_pic_info );
	this.removeChild( flashmo_pic_border );
		
	Tweener.addTween( thumbnail_group, { alpha: 1, time: tween_duration, transition: "easeIn" });
	Tweener.addTween( flashmo_pic, { alpha: 0, time: tween_duration,
					  transition: "easeIn", onComplete: unload_photo });
}

function unload_photo():void
{	
	flashmo_pic.removeChildAt(0);
	photo_property.removeChild( flashmo_pic );
	this.removeChild( photo_property );	
	this.removeChild( flashmo_mask );	
	thumbnail_group.mouseChildren = true;
}

function close_loader():void
{
	try
	{
		pic_loader.close();
		pic_loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, on_photo_progress);
		pic_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, on_photo_loaded);
	}
	catch( e:Error ){}
}

function on_previous_click(me:MouseEvent):void
{
	next_pic_no--;
	load_photo();
}

function on_next_click(me:MouseEvent):void
{
	next_pic_no++;	
	load_photo();
}