Displaying 3 random and unique numbers out of 6

The following program gives me the results in the output panel because I used trace.  The problem is that I want these numbers displayed when I click on a button.  The numbers should not duplicate when the button is clicked, for example not "3, 3, 2" but "3, 2, 5".  Here is the program that randomly selects numbers (which by the way is not mine):   (I'll happily donate 15$ to the animal charity of your choice for whoever can give me a hand with this problem, thanks!)
var mynumbers:Array = ["1","2","3","4","5","6"];
var mystuff:Array = [];
var randomCount:Number = 3;
var r:Number;
for (var i = 0; i<randomCount; i++)
r = Math.floor(Math.random() * mynumbers.length);
mystuff[mystuff.length] = mynumbers.splice(r,1);
trace(mystuff);
//and here is my button code
generate_btn.addEventListener(MouseEvent.CLICK, coco);
//3.;
function coco(event:MouseEvent):void

Hi
I am trying to replace the numbers in the random script with pictures. I thought that all I had to do was replace the numbers in the array with pictures name.
I am getting the output as picture names instead of actual images. I just started flash a few weeks ago and would appreciate where I am going wrong in the code below. I know, it's a bit ambitious for someone who has no experience in programming or mathematical background. I think, that is the only way to learn. By asking the experts in programming. Otherwise, I just give up, and go back to watching TV.
var mynumbers:Array = ["alfa.jpg","beta.jpg","alfa1.jpg","alfa2.jpg","alfa3.jpg","alfa4.jpg"];
var randomCount:Number = 3;
function shuffle(a:Array) {
    var p:int;
    var t:*;
    var ivar:int;
    for (ivar = a.length-1; ivar>=0; ivar--) {
        p=Math.floor((ivar+1)*Math.random());
        t = a[ivar];
        a[ivar] = a[p];
        a[p] = t;
//and here is my button code
generate_btn.addEventListener(MouseEvent.CLICK, coco);
//3.;
function coco(event:MouseEvent):void
shuffle(mynumbers);
for(var i:int=0;i<randomCount;i++){
if(!this["tf_"+i]){
this["tf_"+i]=new TextField();
this["tf_"+i].text = mynumbers[i];
addChild(this["tf_"+i]);
this["tf_"+i].y = i*40;

Similar Messages

  • Choosing serveral random and unique numbers

    Hi
    I'd like to select 9 random numbers out of a set of let's say
    1-20. They can't repeat and each has to be saved into a different
    variable P1-P9.
    Any ideas?
    Thanks

    Make an array of the numbers 1 through 20.
    Shuffle the array.
    Take off as many numbers as you need.
    Search the forums for shuffle to find out how to shuffle the
    array.

  • SAP MDM DISPLAY FIELD AND UNIQUE FIELD DIFFERENCE

    Hi All
    I am new in MDM, can any body please help me understand...
    What is the difference between display field and unique field?
    Besides to consider one field to be a key in a lookup table, how should we declare that field in the table, as a display field or as an unique field?
    It would be helpful if someone kindly explain this to me.
    Thanks in advance.
    Santanu Ghosh

    Hi Santanu,
    To explain you the difference in Display field and Unique filed as in MDM in a prescise manner:
    Display field:
    Every field you create under your main table ie Product atbel will be a displayed field in MDM data manger irrespective of you making it as display or not in Console.
    It means two things
    1) That this field will be visible in MDM data manger.
    2) This field will be visible in Import Manager for Mapping.
    But in case of lookup field you need to make the fields as dispaly or not,if you wish to see them in import manger.
    If you do not make the fields in a lookup table as dsipaly then even though you can see them in MDM data manger you will not be able to see them in Import amnger as a result not be able to map them.
    Unique Field:
    When you make any field as unique it maens taht MDM will not allow you to add two values under this field with the same value.
    Eg:You acnnot add two materials with material no 100.
    Hope it helped
    Kindly reward points if found useful
    Thanks
    Simona

  • Need help in query to display lot and serial numbers for a Wip Job Component

    Hi ALL,
    I have a requirement as below.
    I need to display lot and serial numbers for a Wip Job Component, i have a xml report in that for each wip job component i need to check whether it is a lot control item or serial control item based on that i need to display some data. so can you please help me to get the query to indentify the lot and serial number for a wip job component.
    Thanks

    Thank you for replying Gordon.  I did not remember I had asked this before.  I no longer have access to the other account. 
    What I need on the query is that I want  a list of items with the on order quantity and when we are expecting this order to be received.  The receiving date is based on the PO delivery date.  The trick here is that  I need to Master sku to show the delivery date of the component sku.  In my scenario all components have the same delivery date for the Master sku.  If there are mulitple delivery dates because each warehouse is getting them on a different date then I want to get the delivery date for that warehouse.
    Let me know if this is possible and if yes please guide towards a query for it.
    Thank you.

  • Help Displaying Highest and Lowest Numbers

    Hello everyone, I'm new to Java and I have an issue with my program.
    All it does is randomly select 5 numbers from 1-10 right now, but I want it to display to the user the highest and lowest number that was selected. I'm not entirely sure how to do this so if you could help me that would be great. Here is my program.
    import java.util.Random;
         public class Dice
              public static void main(String[] args)
                   Random generator = new Random();
                   int num1;
                   int num2;
                   int num3;
                   int num4;
                   int num5;
                   int lowestnumber;
                   int highestnumber;
                   System.out.println("Let's roll the 10 sided dice!");
                   num1 = generator.nextInt(11);
                   System.out.println("Roll #1: " + num1);
                   num2 = generator.nextInt(11);
                   System.out.println("Roll #2: " + num2);
                   num3 = generator.nextInt(11);
                   System.out.println("Roll #3: " + num3);
                   num4 = generator.nextInt(11);
                   System.out.println("Roll #4: " + num4);
                   num5 = generator.nextInt(11);
                   System.out.println("Roll #5: " + num5);
    //This is where my problem is, I'm not sure how to go about getting my two integers to read the highest
    //and lowest number.
                   System.out.println("The highest number you rolled was: " + highestnumber);
                   System.out.println("The lowest number you rolled was : " + lowestnumber);
    }

    gmiller4th wrote:
    Hello everyone, I'm new to Java and I have an issue with my program.
    All it does is randomly select 5 numbers from 1-10 right now, but I want it to display to the user the highest and lowest number that was selected. I'm not entirely sure how to do this so if you could help me that would be great. Here is my program.
    import java.util.Random;
         public class Dice
              public static void main(String[] args)
                   Random generator = new Random();
                   int num1;
                   int num2;
                   int num3;
                   int num4;
                   int num5;
                   int lowestnumber;
                   int highestnumber;
                   System.out.println("Let's roll the 10 sided dice!");
                   num1 = generator.nextInt(11);
                   System.out.println("Roll #1: " + num1);
                   num2 = generator.nextInt(11);
                   System.out.println("Roll #2: " + num2);
                   num3 = generator.nextInt(11);
                   System.out.println("Roll #3: " + num3);
                   num4 = generator.nextInt(11);
                   System.out.println("Roll #4: " + num4);
                   num5 = generator.nextInt(11);
                   System.out.println("Roll #5: " + num5);
    //This is where my problem is, I'm not sure how to go about getting my two integers to read the highest
    //and lowest number.
                   System.out.println("The highest number you rolled was: " + highestnumber);
                   System.out.println("The lowest number you rolled was : " + lowestnumber);
    }Instead of having a bunch of separate ints, you could just have one array and use an insertion sorting algorithm...
    http://en.wikipedia.org/wiki/Insertion_sort
    So instead, you would have:
    import java.util.Random;
    public class Dice
    public static void main(String[] args)
    Random generator = new Random();
    int[] nums;
    int lowestnumber;
    int highestnumber;
    System.out.println("Let's roll the 10 sided dice!");
    nums[0] = generator.nextInt(11);
    System.out.println("Roll #1: " + nums[0]);
    nums[1] = generator.nextInt(11);
    System.out.println("Roll #2: " + nums[1]);
    nums[2] = generator.nextInt(11);
    System.out.println("Roll #3: " + nums[2]);
    nums[3] = generator.nextInt(11);
    System.out.println("Roll #4: " + nums[3]);
    nums[4] = generator.nextInt(11);
    System.out.println("Roll #5: " + nums[4]);
    nums = InsertionSorting(nums);
    //The sorting method will sort the number from lowest to highest, thus:
    highestnumber = nums[4];
    lowestnumber = nums[0];
    System.out.println("The highest number you rolled was: " + highestnumber);
    System.out.println("The lowest number you rolled was : " + lowestnumber);
    public static int[] InsertionSorting (int[] a) {
              for (int i = 1; i < a.length; i++ )
                  int value = a;          // next item to be inserted in order
              int j;
              // Back up in the array to find the spot for value.
              for ( j = i - 1; j >= 0 && a[j] > value; j-- )
         // This element is bigger than the element being inserted,
         // so move it up one slot.
         a[j+1] = a[j];
         // a[j] is the item that should precede value.
              // Put value after it.
         a[j+1] = value;
              return a;
    The comments in the insertion sort are not my own... I yoinked it from the web.
    I apologize if there are any errors. Hope it helps
    Edit: __colin  has a good suggestion... you'd want to use something like that as well for error protection.
    Silly me, I just realized that my sorting is way more complicated than it needs to be... But it's fun anyway! -slightly embarassed-
    Edited by: Thok on Oct 11, 2007 9:42 AM
    Edited by: Thok on Oct 11, 2007 9:48 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Displaying Row and Column Numbers

    I see through other research on Oracle SQL Developer that I should be able to display the row and column numbers on version 1.5.4, but I don't see where to go to turn this on. Suggestions?

    Suggestions?Ask in the SQL Developer forum?

  • Display Flicker and Screen Die Outs Randomly

    I bought the MacBook Pro with Retina Display and all good stuff, however, it is giving bad flicker problem and screens seems to die suddently at times. I have to shut off the computer and then turn it on again....
    This is sad and annoying problem. After paying $3500 for a computer, this is painful.
    Can Apple fix this problem easily? Why is Apple not contacting customers and offer to fix this issue?

    The most obvious next-step solution I'm trying to avoid in trouble shooting is a clean install...that takes me down for a 1 full day, plus 2-3 days rebuilding my application preferences, plugins, serialization of sofware, etc. (I know I can use the migration assistant, but don't want to "migrate" the trouble back in to a clean system.)
    In a Mac Pro, you should have a Boot Drive with only System, Library, Applications, and the hidden unix files including paging/swap. All user files (which includes preferences) should be moved to another drive.
    Establishing a Boot Drive is one of the best Speedups you can give your multi-drive Mac. It stops the incessant "snacking" of the system from wrecking data Reads and Writes.
    Once you have a Boot Drive, you can switch to a different one (temporarily or permanently) in a few minutes.

  • How to select  random and unique number

    hi all
    suppose i have millions of rows in emp table
    i want to select group of empno
    group of records would be 10
    all records uniquely selected
    make sure all records are selected in any Group
    thanks

    BluShadow wrote:
    Solomon Yakobson wrote:
    3360 wrote:
    It is the definition of random that the each value generated has an equal chance of being generated again. A coin toss is random despite the result only having two values.Absolutely. Except one little thing. The above applies if we randomly pick from same set. Now OP asked to randomly select group of objects. This is same as you have a set of unique objects and you randomly pick one and put it in your pocket. Then you randomly pick another object and put it in your pocket. So you end up with a UNIQUE set of randomly picked objects in your pocket. Now DBMS_RANDOM allows to specify low & high value but it doesn't allow to provide something like "pick N values" or except list to mimick "put in your pocket" part. That is why we have to write something like I suggested to OP.
    SY.In that case it should just be an answer like...
    select * from tablename where rownum <= 10because the order is not guaranteed without an order by clause and therefore that's just as random as needed to meet the requirements. ;)hi BluShadow
    rownum surely give unique number of records but it will not A RANDOM....
    thanks

  • Random and Unexpected Log Outs

    I have two different eMac's that randomly Log out the user and go to the Log On screen no matter what the user is doing. There is no pattern to it. It can happen once a day or as many as six times a day.
    I've checked Energy Saver, "Sceduled log off" is not turned on. I've also scoured the Console logs and cannot find any entries that looks like a process that might be repsonsible for it. Apple and Google searches find nothing.
    Anyone else had this problem? Glues? I'm at a loss at this point.
    Thanks, Steve
    Dual 1.8 G6   Mac OS X (10.4.5)  

    Hi
    I notice one trouble shooting step that I would definitely try is missing from the article: Remove ALL cache files. 
    You can do this manually, or use Onyx of Snow Leopard Cache Cleaner.  Be sure to reboot immediately.
    Bob

  • Spry Submenu in IE not displaying correctly and appears way out of position

    I have used a horizontal spry menu with submenu's
    (www.nationalbartender.co.uk). Everything works fine except for in
    IE the submenu's look different and they dont hover over everything
    else. Instead they move the content down the page to make room and
    appear horizontally across the page instead of underneath each
    other. A nightmare thats taking ages to sort. If anybody can take a
    quick look at the site. Maybe view it in Safari and then in IE and
    offer any guidance I would appreciate it! cheers.

    I haven't been able to get my site posted up yet. Here is a link to it anyway:andrearosales.com
    I will be working on connecting my files up to my server. At the moment, here are some screen shots of some messages that I am getting when I am saving my file.
    I'm not sure what to make of these messages. I tried to put a new spry horizontal menu bar on my main page, and when it appeared, it displayed as a spry vertical menu bar.
    Here is a picture of what it looks like:
    I"m going to refer to the links that were suggested to me though. I'm not sure if pictures of the code will help to solve my problem. I'm going to try again to connect my files to my server though.

  • I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the Component and Audio ports on my TV?

    I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the MacBook Pro and connected to the TVs Component and Audio in ports.

    Will not work.  To my knowledge, dual converting like that isn't supported.  The Mac must detect the connected video output device and that sort of info cannot be done across an analog component uni-directional connection.

  • .How do I find out what Version (generation) of Ipod touch I have, as I want to know if I can download IOS 5 onto it? It was a gift so I only know the model and serial numbers but not the type

    Hi, can anyone help me out with this question?
    How can I find out which version of Ipod touch I have. I only have the model and serial numbers as it was a gift, but I would like to download IOS 5 if it is compatible?
    Very frustrated Ipod user, any advice would be much appreciated.
    Lynda.

    I had the same problem because there are so many iPod models.  There is a great article in Wikileaks that explains it all and also has pictures.  I'm confident this answer your question.

  • How do you get a list of your contacts nick names and their phone numbers on line and print them out?

    How do you get a list of your contacts nick names and their phone numbers on line and print them out?  I've been trying to figure out how to get the list to print out but I can't even find a complete list to view on Verizon's web site.  Does anyone know how to do this?

    Log into your online account. In the, 'I want to', box type, Manage Contacts.
    Place your cursor over any contact, a pop screen will appear with the option to print your contacts

  • IMac Display stretched and out of focus

    My iMac display is not right. It is slightly enlarged and out of focus. I have already tried the display settings and holding the control key and scrolling down. I also tried restarting. Nothing is working. Last night I tried configuring my router for wireless. I supposedly made it secure with a password, which I had to use to connect to my network. The screen thing happened after that. This morning I checked the connection again and the little lock icon was no longer there. Could the two be related? Please help! I am obviously not very apt with computers, but I'm trying.

    This resolved my issues:
    Preferrences >  Accessibility > Zoom 
    then, uncheck Zoom and uncheck Zoom follows keboard focus. 
    Wait a few minutes.  You can rechec them again but it won't go back to the stretched and out of focus look.  I don't know why.

  • How to split a html page without frames and display random questions

    1) In my online examination application i need to display timer at the top of the page. even if the user
    scrolls down the timer should be visible. is there any way to do this without frames.
    2) questions are displayed randomly for each user. iam using rand() function to retrieve the questions from mysql database. now the problem is if the user refresh the page another set of questions are displayed. how to avoid this.
    thanks

    Hi Thanuja,
    Can you try it with the one below..... and checkout whether tht works or not
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
      </head>
    <script language="javascript">
    var i=0
    function showDate()
    i=i+1
    document.getElementById("staticcontent").innerHTML= "<center><b>Time :  " + i +" secs</b></center>"
    setTimeout("showDate()",1000)
    </script>
    <body onload="showDate()"> 
    <div id="staticcontent" style="position:absolute; border:1px solid black; background-color: lightyellow; width: 135px;">
    </div>
    <script type="text/javascript">
    //define universal reference to "staticcontent"
    var crossobj=document.all? document.all.staticcontent : document.getElementById("staticcontent")
    //define reference to the body object in IE
    var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
    function positionit(){
    //define universal dsoc left point
    var dsocleft=document.all? iebody.scrollLeft : pageXOffset
    //define universal dsoc top point
    var dsoctop=document.all? iebody.scrollTop : pageYOffset
    //if the user is using IE 4+ or Firefox/ NS6+
    if (document.all||document.getElementById){
    crossobj.style.left=parseInt(dsocleft)+5+"px"
    crossobj.style.top=dsoctop+5+"px"
    setInterval("positionit()",100)
    </script>
    <%
    /* JSP LOGIC*/
    %>
    <!-- Customized HTML content -->
    </body>
    </html>REGARDS,
    RaHuL

Maybe you are looking for