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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:45:37+00:00 2026-05-27T13:45:37+00:00

i have some loop function for the game, this loop for open the 9

  • 0

i have some loop function for the game, this loop for open the 9 box, here the code

function random_item_2(coinsx)
{
    var listItem:Array = new Array();
    for (var i:uint=0; i<15; i++)
    {
        listItem.push(i);
    }
    ItemLeft = 0;
    for (var x:uint=0; x<boardWidth; x++)
    {
        for (var y:uint=0; y<boardHeight; y++)
        {
            var thisItem:FirstBox = new FirstBox();
            thisItem.x = x * IcardHorizontalSpacing + IboardOffsetX;
            thisItem.y = y * IcardVerticalSpacing + IboardOffsetY;
            var r:int = Math.floor(Math.random() * listItem.length);
            thisItem.cardface = listItem[r];
            listItem.splice(r,1);
            thisItem.gotoAndStop(thisItem.cardface+2);
            var itemFound = this.foundItem(thisItem.cardface);
            if (itemFound == 50 || itemFound == 100 || itemFound == 250 || itemFound == 500 || itemFound == 1000)
            {
                var itemC = Number(coinsx) + Number(itemFound);
                coinsx = itemC;
                update_coins(Number(coinsx));
                info_coinstext(String(coinsx));
                trace('Gold Coins Found > '+itemFound);
            }else if(itemFound!='Kosong'){
                updateItem(itemFound);
                trace('Item Found > '+itemFound);
            }
            addChild(thisItem);
            ItemLeft++;
        }
    }
}

the problem is, 9 box open in one time, not one by one, i want to box open the box one by one, after the first box opened so the next box will open, here for some algo that i wanted

open the first box
delay 5 sec
open the second box
delay for 5 sec

how i can do that ?

  • 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-27T13:45:38+00:00Added an answer on May 27, 2026 at 1:45 pm

    To add the delay in your for loop you should write something like this:

    function random_item_2(coinsx)
    {
        var listItem:Array = new Array();
        for (var i:uint=0; i<15; i++)
        {
            listItem.push(i);
        }
        ItemLeft = 0;
    
        const DELAY:int = 5000;
    
        for (var x:uint=0; x<boardWidth; x++)
        {
            for (var y:uint=0; y<boardHeight; y++)
            {
                setTimeout(addItem, (x*boardHeight+y)*DELAY, x, y);
            }
        }
    }
    
    function addItem(x:uint, y:uint) : void
    {
        var thisItem:FirstBox = new FirstBox();
        thisItem.x = x * IcardHorizontalSpacing + IboardOffsetX;
        thisItem.y = y * IcardVerticalSpacing + IboardOffsetY;
    
        var r:int = Math.floor(Math.random() * listItem.length);
    
        thisItem.cardface = listItem[r];
        listItem.splice(r,1);
        thisItem.gotoAndStop(thisItem.cardface+2);
    
        var itemFound = this.foundItem(thisItem.cardface);
    
        if(itemFound == 50 || itemFound == 100 || itemFound == 250 || itemFound == 500 || itemFound == 1000)
        {
            var itemC = Number(coinsx) + Number(itemFound);
            coinsx = itemC;
            update_coins(Number(coinsx));
            info_coinstext(String(coinsx));
            trace('Gold Coins Found > '+itemFound);
        }
        else if(itemFound!='Kosong')
        {
            updateItem(itemFound);
            trace('Item Found > '+itemFound);
        }
    
        addChild(thisItem);
        ItemLeft++;
    }
    

    By increasing the delay every time you set the timeout, the function will be called later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cpu-consuming code, where some function with a loop is executed many
I have some divs created dynamically this way: //here goes some loop, and everything
I have some code that invokes anonymous functions within a loop, something like this
I have some code which collects points (consed integers) from a loop which looks
I have created some python code which creates an object in a loop, and
I have a loop like this: for i=1:no %some calculations fid = fopen('c:\\out.txt','wt'); %write
I need some help with an array and a foreach loop, I have an
I have some code that uses the stristr function to extract data I need.
I have some code here : http://bitbucket.org/natim/lo53_tp1/src/tip/part3/camions/medias/js/tracking.js That I use to draw some information
i have some code that requires the use of a for loop to read

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.