Drag scrolling - an unsolved bug

Hi all. I’m new, both to the site and to ActionScripting, and I was hoping that someone here might be able to help me with a small issue I have in a game I’m working on.

I’ve got a play area that’s larger than the stage, and to navigate I’ve put in drag scrolling. For all intents and purposes, this is just dragging the play area and everything on it so it maintains position relative to the mouse. The problem is that there is nothing to stop players from dragging all the content well outside the stage, any distance away from where everything SHOULD be.

I have an idea of how this could be solved, but I don’t know how to code it, nor if it will actually work properly in the first place. So please let me know, or suggest another idea, if it turns out I’m wasting my time with this idea.

The plan is to create two invisible objects: the first is the exact size of the stage, with a position of 0,0; the second is the size of the play area, with a sizable margin. The latter of these two is dragged like the playfield and its content. While the two objects overlap, everything’s fine, but when any part of them doesn’t overlap, a bit of script will find out what edge(s) of object 1 are not being overlapped, and stop the ability to drag in that direction until things are rectified.

Here’s what I don’t know, which that plan would require me to know:

  1. Is it possible to detect when objects aren’t entirely overlapping? I guess I could just make object 2 smaller than planned by twice the dimensions of the play area and use the normal collision detection method, but if it’s possible to do things the other way, it’d be good to know.

  2. I have no idea how to even start working out what edge of object 1 wouldn’t be overlapping.

  3. I also have no idea how to stop dragging in only one direction.

If anyone can help me work out how to do this, I’d greatly appreciate it. If it turns out, of course, that my method is entirely overcomplicated or problematic, I’d also appreciate other suggestions too.

Thanks a lot, in advance.

Matt.