Scrolling Thumbnails - So close to working!

Scrolling Thumbnails - So close to working !!!

I have been using the code here to try and create scrolling thumbnails on MOUSEOVER.

This example scrolls the whole of the MovieClip but I wanted to scroll just the Thumbnails inside a mask

The demo I have HERE is just a MovieClip of images - images.
The images then has a Sprite on top and this Sprite masks the thumbnails below
When I MOUSEOVER the thumbnails I want them to scroll to show the hidden thumbnails

It’s nearly woking but I can’t get it to work correctly. When scrolling to the right I want it to stop
when the last image is shown. Also the first images are hidden.

Any help of this would be greatly appreciated.

http://www.ttmt.org.uk/forum/scroll/


package{
	
	import flash.events.*
	import flash.display.*
	
	public class Doc extends MovieClip{
		
		private var images:MovieClip = new Img();
		private var maskObj:Sprite = new Sprite();
		
		public function Doc(){
			maskObj.graphics.beginFill(0x00ffff);
			maskObj.graphics.drawRect(0,0,800,100);
			maskObj.graphics.endFill();
			addChild(maskObj)
			maskObj.x = maskObj.y = 100;
			//
			addChild(images);
			images.x = images.y = maskObj.y;
			//
			images.mask = maskObj;
			//
			thumbsCanScroll()
		}
		
		private function thumbsCanScroll():void{
			images.addEventListener(MouseEvent.MOUSE_OVER, imagesMOUSEOVER);
			images.addEventListener(MouseEvent.MOUSE_OUT, imagesMOUSEOUT);
		} 
		
		private function imagesMOUSEOVER(e:MouseEvent):void{
			images.addEventListener(Event.ENTER_FRAME, scrollThumbs);
		}
		
		private function imagesMOUSEOUT(e:MouseEvent):void{
			images.removeEventListener(Event.ENTER_FRAME, scrollThumbs);
		}
		
		private function scrollThumbs(e:Event):void{
			var xDist:Number = (mouseX - images.x)/maskObj.width;
			images.x = -xDist*(images.width - maskObj.width);
		}
	}
}