AttachMovie within onEnterFrame

I’m having problems attaching a MC within a onEnterFrame function, it works outside just fine. Here is the code and problem:

var thb = this["image"+icount].container;
	//Load the images from the folder
	thb.loadMovie("01/snap"+icount+".jpg");
	temp = this.createEmptyMovieClip("tmp"+icount, 999);

	imagePreloader._x = 10;
	imagePreloader._y = image._y+Yval;
**[COLOR=Red]//Works fine here[/COLOR]	**
**imagePreloader.attachMovie("SessionLoader","SessionLoader",99);**
	
	thb._alpha = 0;

	
	**[COLOR=Blue]temp.onEnterFrame [/COLOR] ** = function() {
		var t = thb.getBytesTotal();
		var l = thb.getBytesLoaded();
	**[COLOR=Red]// But won't attach here ?[/COLOR]	**
		

Any ideas?
Thanks