A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Horizontal scrolling a MC with deceleration?

  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    54

    Horizontal scrolling a MC with deceleration?

    I'm trying to create a scrolling effect much like the one viewable here:

    http://www.humaniz.com/work/

    Which scrolls left/right depending on the mouse position. I found some (old, old) code that kind of does the trick. After determining that the mouse _y position is correct, it kicks into this looping frame to move the large movieclip:

    Code:
    mouseposition = getProperty("/myself", _x);
    iconsposition = getProperty("/icons", _x);
    if (Number(mouseposition)>=400 and Number(iconsposition)>Number(-220)) {
    	setProperty("/icons", _x, iconsposition-(0.1*(mouseposition-400)));
    }
    if (Number(mouseposition)<300 and Number(iconsposition)<1034) {
    	setProperty("/icons", _x, Number(iconsposition)+Number((0.1*(300-mouseposition))));
    }
    However the code is kinda ancient, and doesn't decelerate when it reaches either end of the movieclip it's scrolling.

    Is there an elegant way to handle this?

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Hi,

    That's Flash 4 code.

    I suggest you take a look at Robert Penner's easing equations.
    And search the forums, as you'll find lots of examples.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center