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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:04:12+00:00 2026-06-14T05:04:12+00:00

I am doing a random number generator with 5 dynamic text. what I want

  • 0

I am doing a random number generator with 5 dynamic text. what I want to do is that when showRandom_txt = 1 then the other texts should be equal to zero

//1.
function randomNumbers(min:Number,max:Number) {
   var Results:Number=Math.floor(Math.random()*max)+min;
   return Results;
}

function randomNumber(){
   var Results:Number=Math.floor(Math.random()*(1+1-0))+0;
   return Results;
}


//2.
generate_btn.addEventListener(MouseEvent.CLICK, showRandomnumber);

//3.
function showRandomnumber(event:MouseEvent):void{
   showRandom_txt.text = randomNumber();
   showRandom2_txt.text = randomNumbers(0,9);
   showRandom3_txt.text = randomNumbers(0,9);
   showRandom4_txt.text = randomNumbers(0,9);
   showRandom5_txt.text = randomNumbers(0,9);
}

i am new to AS3 and i would really apreciate your help. thanks

  • 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-14T05:04:13+00:00Added an answer on June 14, 2026 at 5:04 am

    To evaluate equality use the == operator.

    This could be tested from the text field, as in:

    if(showRandom_txt.text == "1") {}
    

    Perhaps better would be test against numeric type, as in:

    var n:Number = randomNumber();
    if(n == 1) {}
    

    Using an if / else implementation:

    function showRandomNumber(event:MouseEvent):void
    {
        var n:Number = randomNumber();
        showRandom_txt.text = n.toString();
    
        if (n == 1)
        {
            showRandom2_txt.text = showRandom3_txt.text = showRandom4_txt.text = showRandom5_txt.text = "0";
        }
        else
        {
            showRandom2_txt.text = randomNumbers(0, 9).toString();
            showRandom3_txt.text = randomNumbers(0, 9).toString();
            showRandom4_txt.text = randomNumbers(0, 9).toString();
            showRandom5_txt.text = randomNumbers(0, 9).toString();
        }
    }
    

    Using a switch block:

    function showRandomNumber(event:MouseEvent):void
    {
        var n:Number = randomNumber();
        showRandom_txt.text = n.toString();
    
        switch(n)
        {
            case 1:
                showRandom2_txt.text = showRandom3_txt.text = showRandom4_txt.text = showRandom5_txt.text = "0";
                break;
            default:
                showRandom2_txt.text = randomNumbers(0, 9).toString();
                showRandom3_txt.text = randomNumbers(0, 9).toString();
                showRandom4_txt.text = randomNumbers(0, 9).toString();
                showRandom5_txt.text = randomNumbers(0, 9).toString();
                break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use a random number generator that creates random numbers in a
I am looking for a seeded random number generator that creates a pool of
I'm doing some random experimentation and want to print out the address the program
I need to random some elements from an array. I'm doing that by randomizing
Possible Duplicate: Random number generator not working the way I had planned (C#) I
I am creating random number generator in Java as part of program I am
I'm running into an issue with the random number generator I wrote for a
I want to repeat a random number sequence generated by a legacy software using
I understand that time is an insecure seed for random number generation because it
Problem fixed, see below What I'm doing is this: Generate random number -> store

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.