Display list woes

Hi,

I’ve been writing some code to create a scrolling pane without the scrollbar.
Essentially, when the cursor is within the pane to be scrolled, I want the pane to be scrolled at a speed proportional to the distance the cursor is from the horizontal centre-line of the pane.

The code all works fine if it’s there’s no children of the Sprite to be scrolled.
Also, when using some sort external box as the scrolling control instead of the Sprite itself, all works fine as well. But when I try to use the Sprite that is to be scrolled as the “slider” it all starts to go wrong. The child Sprites seem to block events flowing up the tree to the Sprite I’m trying to scroll. Then again, it might be something else. I’ve been trying the mouseChildren property to no avail.

Here’s the code:

(Thanks for any help)
**
EasyScroll.as**



package 
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;

    public class EasyScroll extends Sprite
    {
        var rect:Rectangle;
        var scrollSpeed:Number;
        var scrollRectHeight:int;
        var contentHeight:uint;
        var clip:Sprite;
        var clipY:int;
        
        public function EasyScroll(SpriteToScroll:Sprite, scrollRectH:int)
        {
            scrollRectHeight = scrollRectH;
            clip = SpriteToScroll;
            clipY = clip.y;
            contentHeight = clip.height;// the textField's height
            clip.scrollRect = new Rectangle(0, 0, clip.width, scrollRectHeight);
            clip.cacheAsBitmap = true;
            clip.addEventListener(MouseEvent.MOUSE_OVER, scrollHandler);
            clip.addEventListener(MouseEvent.MOUSE_OUT, stopScroll);
        }

        function scrollHandler(event:MouseEvent):void
        {
            // Add listener to capture the mouse position
            // The listener dispatches the event to the moveScrollRect function
            //   which adds another event listener for ENTER_FRAME, which is dispatched to bumpY function.
            clip.addEventListener(MouseEvent.MOUSE_MOVE, moveScrollRect);
        }
        
        function stopScroll(ev:Event):void
        {
            clip.removeEventListener(MouseEvent.MOUSE_MOVE, moveScrollRect);
            clip.removeEventListener(Event.ENTER_FRAME, bumpY);
        }

        function moveScrollRect(ev:MouseEvent):void
        {
            rect = clip.scrollRect;
            scrollSpeed = 0.4*( (clip.mouseY-rect.y) - (scrollRectHeight/2) );
            //trace("mouseY: "+clip.mouseY+", target: "+ev.target.name+", scrollSpeed: "+scrollSpeed+", rect.y: "+rect.y);
            if ( clip.hasEventListener(Event.ENTER_FRAME) == false )
            {
                clip.addEventListener(Event.ENTER_FRAME, bumpY);
            }
        }

        function bumpY(ev:Event):void
        {
            rect = clip.scrollRect;
            //if scrolling up
            if (scrollSpeed < 0)
            {
                // if not at "top"
                if (rect.y + scrollSpeed >= 0)
                {
                    rect.y += scrollSpeed;
                    clip.scrollRect = rect;
                } else if (rect.y > 0)
                {
                    // make scrollSpeed less negative so can scroll right to top
                    scrollSpeed += 1;
                    rect.y += scrollSpeed;
                    clip.scrollRect = rect;
                }
            } else if ( rect.y < contentHeight-clip.height )
            {
                rect.y += scrollSpeed;
                clip.scrollRect = rect;
            }
        }
    }
}

scrollerTest.fla:

var circleArray:Array = new Array();

var containerSprite:Sprite = new Sprite();
containerSprite.name = "cont";
containerSprite.graphics.beginFill(0xEEEEEE);  
containerSprite.graphics.drawRect(0,0,150,500);
addChild(containerSprite);

function printCircle(x:Number, y:Number, radius:Number, name:String, color:uint):void
{
    var circle:Sprite = new Sprite();
    circle.name = name;
    circle.graphics.beginFill(color);
    circle.graphics.drawCircle(x, y, radius);
    circleArray.push(circle);
}

printCircle(0,190,25,"green1",0x00FF00);
printCircle(20,140,35,"green2",0x00FF00);
printCircle(120,200,15,"blue1",0x0024DD);
printCircle(140,270,20,"blue2",0x0000FF);

for (var i:int = 0; i < circleArray.length; i++)
{
    containerSprite.addChild(circleArray*);
}

var events_scroller:EasyScroll = new EasyScroll(containerSprite, 150);