Groups | Blog | Home
all groups > flash actionscript > march 2006 >

flash actionscript : Scrolling Background


Ginger85
3/30/2006 9:38:36 PM
Hello..

I am building a website and I would like the background to scroll along when
the mouse cursor touches the edges of the screen. Basically like this:
http://www.pspartgallery.com/
Any suggestions would be more than welcome!

Thanks,
Ginger
2m
3/30/2006 9:56:25 PM
Hi Ginger,

it is not hard to do, at least with some experinence that is.
You pack your background (or whatever it is that should scroll) into a
movieclip. The you check onMouseMove if the cursor is near one edge of the
stage, and move the clip accordingly.

Do you understand what I'm saying? If not go on asking.

M
Ginger85
3/30/2006 10:53:32 PM
This makes sense, but how do you specify that the onMouseMove should work when it is near the edges of the stage?

2m
3/30/2006 11:33:14 PM
laets say your satage is 500px high, and the area where you want the movie to
move is 20 px from the upper and lower end of the stage it would be:

(beware of typos it's just for the general idea of it)

_root.onMouseMove() = function(){
if (_root._ymouse < 20){
bgr_mc.onEnterFrame = function(){
this._y -= 5; // 10 if you want it to scroll faster, 2 for slower...
}
}
else if (_root._ymouse > 480){
bgr_mc.onEnterFrame = function(){
this._y += 10;
}
}
else {
delete bgr-MC.onEnterFrame;
}
updateAfterEvent();
}

You would have to make sure to stop before your movie runs offscreen and also
deletinf the onEnterFrame function only when necessary would be a good idea,
but as a startingpoint that should do.

M
AddThis Social Bookmark Button