Preloading MC with % preloader

I have some simple code below and I am only lacking one small piece to make it complete. I need a little preloaded function that calculates the size of the movie clip and that is being loaded into the the holder_mc. This % should be show in in loading_txt. After the loading hits 100%, the function contract should be called. I can’t seem to work out a functional preloader.

Just cut and paste the code, and make a movie called test.swf in the same folder, and it should test fine. Make sure test.swf has something in it to increase the file size.

Any suggestions would be greatly appreciated. Thanks :o



// IMPORT CLASSES
import mx.transitions.Tween;
import mx.transitions.easing.*;
//CREATE HOLDER MOVIE CLIP
createEmptyMovieClip("holder_mc", getNextHighestDepth());
with (this.holder_mc) {
	moveTo(0, 0);
}
// CREATE BOX 
createEmptyMovieClip("box", getNextHighestDepth());
with (this.box) {
	lineStyle(1, 0x000000, 100);
	beginFill(0xFF6600, 100);
	moveTo(0, 0);
	lineTo(980, 0);
	lineTo(980, 600);
	lineTo(0, 600);
	lineTo(0, 0);
	endFill();
}
//CREATE PRELOADER
createTextField("loading_txt", getNextHighestDepth(), 50, 10, 50, 22);
loading_txt.multiline = false;
loading_txt.wordWrap = false;
loading_txt.text = "100";
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0xFF0000;
my_fmt.font = "Arial";
my_fmt.size = 12;
my_fmt.bold = true;
loading_txt.setTextFormat(my_fmt);
// CREATE BUTTON
createEmptyMovieClip("button1", getNextHighestDepth());
with (this.button1) {
	lineStyle(1, 0x000000, 100);
	beginFill(0xFFFF00, 100);
	moveTo(0, 0);
	lineTo(20, 0);
	lineTo(20, 20);
	lineTo(0, 20);
	lineTo(0, 0);
	endFill();
}
//-------------------------------- Functions -------------------------------------//
// DEFINE TWEENS for mask
function contract() {
	easeType = Strong.easeInOut;
	contract1 = new Tween(box, "_yscale", easeType, 100, 0, 1, true);
}
function expand() {
	easeType = Strong.easeInOut;
	expand1 = new Tween(box, "_yscale", easeType, 0, 100, 1, true);
}
//load Movie functions
function loadIt(clip:MovieClip) {
	loadMovie(clip, holder_mc);
}
// CALL TWEENS
button1.onRelease = function() {
	expand();
	expand1.onMotionFinished = function() {
		//load movie code here
		loadMovie("test.swf", holder_mc);
		trace("Yes");
		contract();
		//call contract after percent_txt = 100
	};
};
//load variable
var pctLoaded:Number = Math.round(holder_mc.getBytesLoaded()/holder_mc.getBytesTotal()*100);

contract();