?
Solved

Flash MX actionscript random number array

Posted on 2007-09-28
3
Medium Priority
?
2,541 Views
Last Modified: 2010-05-19
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");
}
0
Comment
Question by:imagicstudios
2 Comments
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 19979849
problem is in following line of code:

var txttitle:String = myArray[ary];

"ary" is an array, how can it be used as index number for array "myArray"

-------------------
Aneesh Chopra
-------------------
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20212409
Forced accept.

Computer101
EE Admin
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question