Interactive Image Panning (flash cs3/as3 version)?

Is there a as3 version (flash cs3) for the following tutorial?
http://www.kirupa.com/developer/flash8/interactive_image_pan.htm

My intension is to put all the code in a separated .as file as supposed to writing everything in the timeframe, using the package definition.

the problem I encountered is the (onEnterFrame) part… not sure how to seperate this (the doMove() function) as a standalone private function rather than be settled inside *constrainedMove() *…?
here’s the code I have so far:


package
{
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.events.*; //for Event.MOUSE_UP/DOWN etc (enums)

    public class testPanning extends Sprite
    {
        // Constructor
        public function testPanning()
        {
            var child:Sprite = new Sprite();
            child.addEventListener(MouseEvent.MOUSE_DOWN , mouseDownHandler);
            
            addChild(child);
        }
        
        private function mouseDownHandler(evt:MouseEvent):void
        {
            _constrainedMove(bg_mc, 4, 1);
        }
        
        // a better way to define this part? *******
        private function mouseUpHandler(evt:MouseEvent):void
        {
            doStop();
        }
        
        private function imageScrollHandler(evt:Event, target:MovieClip):void
        {
            if (target.x == target.destX) 
            {
                target.removeEventListener(Event.ENTER_FRAME, doMove)
            } else { 
                target.x += Math.ceil((target.destX-target.x)*(speed/100));
            }
        }
        
        //not sure how this should work *******
        private function doImageScroll(target:MovieClip):void
        {
            e = new Event();
            imageScrollHandler(e, target); 
        }
        
     
        private function _constrainedMove(target:MovieClip, speed:Number, dir:Number):void
        {
            //
            var mousePercent:Number = mouseX/stage.stageWidth;
            var mSpeed:Number;
            if (dir == 1) {
                mSpeed = 1-mousePercent;
            } else {
                mSpeed = mousePercent;
            }
            
            target.destX = Math.round(-((target.width - stage.stageWidth)*mSpeed));
            
            //not sure how this should work *******
            doImageScroll(target);
            
            //
            target.addEventListener(Event.ENTER_FRAME, doMove);
            target.addEventListener(MouseEvent.MOUSE_UP, doStop); //*******

        
            function doStop(evt:MouseEvent):void
            {
                target.removeEventListener(Event.ENTER_FRAME, doMove);
            }
        }
        
    } //EOF public class testPanning
}//EOF package

Those problematic blocks are marked with *******.

Sorry for the mess but I am not asking to fix my code… just need some hints how to lay it out more neatly, as well as for a better practice :dog:

This following is the new Flash CS3 Project I’ve migrated: (Firefox is recommended for downloading)
http://www.driveway.com/jjjze78217