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 8163585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:05:50+00:00 2026-06-06T19:05:50+00:00

My question is, which one is better to use? How to properly use a

  • 0

My question is, which one is better to use? How to properly use a switch statement. Should I use variables or not etc. I thank you in advance for your reply. “random text because I need a lot of explanation or else it won’t let me post.”

switch(level_id)
{
    case 1:
        stage.addChild(new lvl(50, 200, 100, level_id));
        break;
    case 2:
        stage.addChild(new lvl(50, 200, 100, level_id));
        break;
    case 3:
        stage.addChild(new lvl(50, 200, 100, level_id));
        break;
    case 4:
        stage.addChild(new lvl(50, 200, 100, level_id));
        break;
    case 5:
        stage.addChild(new lvl(50, 200, 100, level_id));
        break;
    case 6:
        stage.addChild(new lvl(50, 200, 100, level_id));
        break;
    case 7:
        stage.addChild(new lvl(50, 200, 100, level_id));
        break;
    default:
        break;
}

or

switch(level_id)
{
    case 1:
        x = 50; y = 200; x = 100;
        break;
    case 2:
        x = 50; y = 200; x = 100;
        break;
    case 3:
        x = 50; y = 200; x = 100;
        break;
    case 4:
        x = 50; y = 200; x = 100;
        break;
    case 5:
        x = 50; y = 200; x = 100;
        break;
    case 6:
        x = 50; y = 200; x = 100;
        break;
    case 7:
        x = 50; y = 200; x = 100;
        break;
    default:
        break;
}
stage.addChild(new lvl(x, y, z, level_id));

What I finally did (edit)

Final result, thanks all

var config:Object = {
               "1":{ "paddWidth":50, "blockWidth":200, "blockHeight":100 },
               "2":{ "paddWidth":50, "blockWidth":200, "blockHeight":100 },
               "3":{ "paddWidth":50, "blockWidth":200, "blockHeight":100 },
               "4":{ "paddWidth":50, "blockWidth":200, "blockHeight":100 },
               "5":{ "paddWidth":50, "blockWidth":200, "blockHeight":100 },
               "6":{ "paddWidth":50, "blockWidth":200, "blockHeight":100 },
               "7":{ "paddWidth":50, "blockWidth":200, "blockHeight":100 },
               "8":{ "paddWidth":50, "blockWidth":200, "blockHeight":100 }
            };

            stage.addChild(new lvl( 
                        config[level_id].paddWidth,
                        config[level_id].blockWidth,
                        config[level_id].blockHeight,
                        level_id
                        ));
  • 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-06-06T19:05:51+00:00Added an answer on June 6, 2026 at 7:05 pm

    Another option might be (untested code):

    var config:Object = {
       "1":{ "x":50, "y":100, "z":150 },
       "2":{ "x":51, "y":101, "z":151 },
       "3":{ "x":52, "y":102, "z":152 },
       "4":{ "x":53, "y":103, "z":153 },
       "5":{ "x":54, "y":104, "z":154 },
       "6":{ "x":55, "y":105, "z":155 },
       "7":{ "x":56, "y":106, "z":156 },
       "8":{ "x":57, "y":107, "z":157 }
    };
    x = config[level_id].x;
    y = config[level_id].y;
    z = config[level_id].z;
    stage.addChild(new lvl(x, y, z));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is which one is better to use? As NSTimer in turn uses
I had a question answered which raised another one, why following does not work?
Which one is better in, say, parameter type in a method (not related to
I am learning JPA and have one question: In which situations we need more
The question has two parts, one of which I already have the answer for.
I want to implement this view But I have one question: The text which
I have a question regarding the some data which is being transfered from one
I was puzzled with one of the question in Microsoft interview which is as
Basically, I have the same question as this one , which unfortunately never got
I wanted to know which one amongst Style and UserControl would be better 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.