Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE FLASH: HomeFlash ForumFlash TutorialsFlash Video TutorialsWeb Streaming ForumAdobe FlashPodcast

math.round to multiple of x?

Cow Forums : Adobe Flash
VIEW POSTS   •   ADD A NEW POST   •   SEARCH   •   CHANGE FORUM
Respond to this post   •   Return to posts index   •   Read entire thread


math.round to multiple of x?
by Carl__F on Nov 4, 2005 at 11:35:42 am

Hi peeps,

One for the math code heads.

I have a scroll bar that is scolling a project list (each project being dynamically loaded). Currently the buttons at either end of the scroll bar shift the list by x amount (being the height of a project window) so that the projects are lined up neatly in the view. You can see what I mean on the site (navigate to recent work and scroll the projets with the buttons) http://www.mainframe.co.uk .

I am now adding drag function to the slider. This means the list moves freely in relation the slider being dragged. However, when the slider is released the project list won't be lined up correctly as it is dependant on the users final drag position.

So here is what I want to acheive. Say the list should move by 150 pixels each time so the projects stay lined up correctly. How do I find the nearest multiple of 150 to the new list position? Example, the user drags the slider and the list moves by 340 pixels. The list would need to move back to 300 and not forward to 450. Can I specify a multiple of 150 in the math.round script? Is this even possible?

Hope I've made my question clear enough.

Thanks for any input.

Regards, Carl


Respond to this post   •   Return to posts index   •   Read entire thread


Current Message Thread:




Note: If you are a registered user please click here to login before posting.

Your post will not be accepted if your name and email address are not registered in our database. Click here if you do not have an account.

Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message   Entire Thread   None  

Message:



Note: The following are HTML characters and may cause parts of your post to disappear if not used correctly: < > &
To include any portion of the post in your response, highlight the desired text and hit the "Q" key. Read more...



Add your message signature


 


Note: By clicking "Post Direct" button above, you are agreeing to the Creative Cow's Code of Conduct.



FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]