Link to home
Create AccountLog in
Avatar of imagicstudios
imagicstudios

asked on

Flash MX actionscript random number array

Hi Experts

I hope that someone can point this code in the right direction for me!

I am developing a hybrid page with php and flash.

I am trying to generate an array of 5 random numbers, that are unique, for a looped flash movie that is displaying info from a database table.

As the Flash file loops it uses the countedvar++ loop to select the next number in the array and pull the data from the database

When I tested this as a simple random number version it all works fine and the page displays the correct text so I am happy that it all works. Now that I am tring to generate a unique number   ....we'll i'm lost.

this code below just gives me  "undefined"

Anyone who can turn this around - big points bonus weekend!!

var txttitle:String = txttitle;

var myArray:Array = txttitle.split(",");

      
      function randList(M,N) {
      ary = [];
      for (i=1; i<M && N>0; ++i) {
            if (random(M-i)<N) {
                  ary.push(i+1);
                  
                  N--;
            }
      }
      return(ary);
      trace(ary);
}
var myArray:Array  = randList(12,4);
var txttitle:String = myArray[ary];

if (this.countedVar <= 0) {


this.countedVar++
}
else if(this.countedVar < 4) {




} else {
_root.gotoAndPlay ("close");
}
ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Forced accept.

Computer101
EE Admin