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

  • Home
  • SEARCH
  • 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 533889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:33:18+00:00 2026-05-13T09:33:18+00:00

Below I have an array that works but it is far too long and

  • 0

Below I have an array that works but it is far too long and I am thinking there is a far easier way to generate the same result using a loop but I just can’t get my head around it at the moment. The array is as follows:

var CardDeck = new Array();
CardDeck[0] = new C1();
CardDeck[1] = new C2();
CardDeck[2] = new C3();
CardDeck[3] = new C4();
CardDeck[4] = new C5();
CardDeck[5] = new C6();
CardDeck[6] = new C7();
CardDeck[7] = new C8();
CardDeck[8] = new C9();
CardDeck[9] = new C10();
CardDeck[10] = new C11();
CardDeck[11] = new C12();
CardDeck[12] = new C13();
CardDeck[13] = new D1();
CardDeck[14] = new D2();
CardDeck[15] = new D3();
CardDeck[16] = new D4();
CardDeck[17] = new D5();
CardDeck[18] = new D6();
CardDeck[19] = new D7();
CardDeck[20] = new D8();
CardDeck[21] = new D9();
CardDeck[22] = new D10();
CardDeck[23] = new D11();
CardDeck[24] = new D12();
CardDeck[25] = new D13();
CardDeck[26] = new H1();
CardDeck[27] = new H2();
CardDeck[28] = new H3();
CardDeck[29] = new H4();
CardDeck[30] = new H5();
CardDeck[31] = new H6();
CardDeck[32] = new H7();
CardDeck[33] = new H8();
CardDeck[34] = new H9();
CardDeck[35] = new H10();
CardDeck[36] = new H11();
CardDeck[37] = new H12();
CardDeck[38] = new H13();
CardDeck[39] = new S1();
CardDeck[40] = new S2();
CardDeck[41] = new S3();
CardDeck[42] = new S4();
CardDeck[43] = new S5();
CardDeck[44] = new S6();
CardDeck[45] = new S7();
CardDeck[46] = new S8();
CardDeck[47] = new S9();
CardDeck[48] = new S10();
CardDeck[49] = new S11();
CardDeck[50] = new S12();
CardDeck[51] = new S13();

Can someone tell me how to put that together into a loop that will generate the same results?

Thanks
Ben

  • 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-13T09:33:18+00:00Added an answer on May 13, 2026 at 9:33 am

    You could use getDefinitionByName to get references to the numbered card classes, something like this:

    import flash.utils.getDefinitionByName;
    
    var deck:Array = [];
    var suits:Array = ['C', 'D', 'H', 'S'];
    var card:Class;
    
    for each(var suit:String in suits) {
        for(var i:int = 1; i <= 13; i++) {
            card = getDefinitionByName(suit + i) as Class;
            deck.push(new card());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a figure below: And my question is that the objects in Array
I have a variable that contains an array from form data, seen below: $option1
I have this basic auto complete JavaScript that works well, but you need to
The below script works fine but only for the first record in the array.
i have an array below string stringArray = new stringArray[12]; stringArray[0] = 0,1; stringArray[1]
I have an array,something like below MutableArray ( { a = 1; b =
I have an Array like below in PHP array( (int) 0 => array( 'id'
i have an array like below int[] array = new array[n];// n may be
I have an array of array like below with all numeric values. I want
I have an array of as given below. For example: array = [20%,*,30%, 10%]

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.