Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6065301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:22:31+00:00 2026-05-23T09:22:31+00:00

I was working on something and I have this chunky bit of code in

  • 0

I was working on something and I have this chunky bit of code in there:

if(contents.x>-199 && contents.x<-1) {
    mcPosX = 0;
} else if(contents.x>-399 && contents.x<-201) {
    mcPosX = -200;
} else if(contents.x>-599 && contents.x<-401) {
    mcPosX = -400;
} else if(contents.x>-799 && contents.x<-601) {
    mcPosX = -600;
} else if(contents.x>-999 && contents.x<-801) {
    mcPosX = -800;
} else if(contents.x>-1199 && contents.x<-1001) {
    mcPosX = -1000;
} else if(contents.x>-1399 && contents.x<-1201) {
    mcPosX = -1200;
} else if(contents.x>-1599 && contents.x<-1401) {
    mcPosX = -1400;
} else if(contents.x>-1799 && contents.x<-1601) {
    mcPosX = -1600;
} else if(contents.x>-1999 && contents.x<-1801) {
    mcPosX = -1800;
} else if(contents.x>-2199 && contents.x<-2001) {
    mcPosX = -2000;
} else if(contents.x>-2399 && contents.x<-2201) {
    mcPosX = -2200;
} else if(contents.x>-2599 && contents.x<-2401) {
    mcPosX = -2400;
} else if(contents.x>-2799 && contents.x<-2601) {
    mcPosX = -2600;
} else if(contents.x>-2999 && contents.x<-2801) {
    mcPosX = -2800;
} else {
    //mcPosX = contents.x;
}

basically I have a long movieclip (much wider than the stage), it snaps to certain points as you drag it around, depending on which section is shown on the screen.

I feel like this section is really long and I’m trying to improve my AS3. Can this be shortened/improved at all?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:22:31+00:00Added an answer on May 23, 2026 at 9:22 am

    Hard to determine exactly what you’re trying to do, butI think this might help you on the right direction:

    mPos.x -= (Math.floor(contents.x / 200) * 200);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some really complicated legacy code I've been working on that crashes when
I believe something on this code chunk is not properly coded making it incompatible
Say I have some data like this: number_stream = [0,0,0,7,8,0,0,2,5,6,10,11,10,13,5,0,1,0,...] I want to process
I have a threaded console application that is working fine, but it's architecture needs
I am working on a simple console app to get my feet wet with
After searching around a bit and consulting the Dinosaur Book, I've come to SO
I have a class Customer (with typical customer properties) and I need to pass
I have an application which will use WCF to serve up various chunks of
I'm writing an iPhone app which fetches an XML file, parses it and then
<tl;dr> In source version control diff patch generation, would it be worth it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.