2 Replies Latest reply on Jun 19, 2006 6:46 AM by *petr

Slide smooth

Hi,

i have drawed a rectangle on my stage, which on mouseEnter scrolls the background image 10 pixels to the left/right/up/bottom etc. It uses the following function.

Now i was wondering if it is possible to create a smooth slow to fast scroll.

For example: the rectangle is 50 pixels width, the first 5 pixels is speed 1 the second speed 2 etc. When i use seperate retangles, it does not seem to go smooth. So i guess i need some math for calculate the speed. Pixel 1, speed=0.2, pixel 2, speed=0.4 etc. Something like this to make a smooth scroll.

Basicly i want to create a smooth scroll depending on the location of the mouse cursor.

Hope someone understands what i am talking about and know how to create that sort of thing.

• 1. Re: Slide smooth
Here's the simplified and expanded version of your behavior that I used in my hard-coded bare-bones test:

property pScene
property pNum
property pDirection
property pAcceleration

on beginSprite(me)
pScene = 2
pDirection = "Left"
pNum = 0
pAcceleration = 0.1
end

on mouseWithin me
case (me.pDirection) of
"Left":
moveLeft(pScene, pNum)
pNum = max(2, pNum + pAcceleration)
end case

end

on moveLeft theSprite, scrollSpeed
if sprite(theSprite).locH < 800 then
sprite(theSprite).locH = sprite(theSprite).locH + scrollSpeed
--moveAllSpriteItems("H", "plus", scrollSpeed)
end if

end moveLeft
• 2. Re: Slide smooth
Looks like my complete version.

But the speed is the same on the whole rectangle. How to make it depend on the position of the mouse. For example; when the cursor moves more to the left, the speed increases.