Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Check If Array Has Numbers



I have an Array that has users IDs some are only Alpha and some are only Numeric. I want to search my array and remove the Numeric values from the array so I only see the Alpha values when displayed. I know I need to use Array.splice to remove the value from the array but I am not sure how to identify if a value is a number and not a name. The ID numbers are random and can range from 1 digit to 10 digits.Is there any way to confirm if an Array value is a number?Thank you;Raymond



Adobe > ActionScript 1 and 2
Posted on: 07/28/2008 12:23:30 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Input Box, Check For 5 Characters, But They Should Be Numbers Only
here is my code:on(release){
if (inPut.length == 5) {
_root.gotoAndPlay("play");
}else{
inPut = "";
}
}
How do I make sure the input box only contains numbers? Thanks guys!!

Check Whether Characters In Input Textfield Are Numbers Or Letters?
I just can't get this right.
I have two textfields:inputTxt (INPUT)
statusTxt (DYNAMIC)
I have a button, which when pressed should check whether the characters entered into the input field are numbers or letters.
I have tried:

Code:
private function onMouseUp(evt:MouseEvent):void {
if (isNaN(inputTxt.text)) {
statusTxt.text = 'You have not entered a number';
}else {
statusTxt.text = 'You have entered a number';
}
}
I realise now that isNAN() only checks a variable value rather than a string value.
How does one do this?

Check Whether Characters In Input Textfield Are Numbers Or Letters?
I just can't get this right.
I have two textfields:

1. inputTxt (INPUT)
2. statusTxt (DYNAMIC)

I have a button, which when pressed should check whether the characters entered into the input field are numbers or letters.
I have tried:

private function onMouseUp(evt:MouseEvent):void {
if (isNaN(inputTxt.text)) {
statusTxt.text = 'You have not entered a number';
}else {
statusTxt.text = 'You have entered a number';
}
}

I realise now that isNAN() only checks a variable value rather than a string value.
How does one do this?

Different Numbers In Array's
Macromedia Flash MX 2004
I have a script (as told before, for those who read it) which creates a small 2d isometric map 10x10 tiles. Right now the number 0 is set to be nothing, 1 is set to be a tile but how can i make nr. 2, 3 and 4 etc become something else? I have my code here:

// Setup
fscommand("allowscale","false");
width = 40;
height = 20;
tiles = 100;
// Iso-Feld
rows = new Array();
rows[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
rows[1] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
rows[2] = [1, 0, 0, 0, 2, 0, 0, 0, 1, 1];
rows[3] = [1, 0, 1, 1, 1, 1, 1, 0, 1, 1];
rows[4] = [1, 0, 1, 0, 0, 0, 1, 0, 1, 1];
rows[5] = [1, 0, 1, 0, 1, 1, 1, 0, 1, 1];
rows[6] = [1, 0, 1, 0, 0, 0, 0, 0, 1, 1];
rows[7] = [1, 0, 1, 1, 1, 1, 1, 1, 1, 1];
rows[8] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1];
rows[9] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
//
movieclip.prototype.iso_nums =function (mcid, w, h, xPos, yPos) {
empty_x = new Array();
empty_y = new Array();
for (var x = 0; x<rows.length; x++) {
for (var y = 0; y<rows[x].length; y++) {
n++;
if (rows[x][y] == 0) {
empty_x[n] = (xPos+(y-x)*w/2);
empty_y[n] = (yPos+(x+y)*h/2);
} else if (rows[x][y] == 1) {
attachMovie(mcid, mcid+n, n*10);
this[mcid+n]._x = xPos+(y-x)*w/2;
this[mcid+n]._y = yPos+(x+y)*h/2;
this[mcid+n].xen = x
this[mcid+n].yen = y
this[mcid+n].number = rows[x][y];
}
}
}
}
//
//Numes is not in use, it was part of a test when i tried to solve the problem myself
iso_numes("tile", 40, 20, 275, 130);
iso_nums("plant", 40, 20, 275, 130);
//

Sum Of Numbers Array?
Hello fellow Actionscripters,

I'm curious and I know there are many ways, but anyone have a good solution towards adding up the numbers in an array minus it's current node?

If I am at myNumbers[3] for example, how do I add everything to the left of my current node such as myNumbers[2], myNumbers[1], myNumbers[0]?

var myNumbers:Number = ["123", "45", "111", "54"];

Thanks in advance, geniuses..

-w

Sorting An Array Of Numbers
o man..flash is so annoying sometimes...

here's the deal..i have to sort a list of numbers..say :

temp = new Array (1,25,101,23,52,52,92,4)

everybody knows that is should generally turn out to be :
(1,4,23,25,52,52,92,101) or compeletely reverse depending on the sort right?

now, flash, when i use temp.sort(), it returns :
(101,1,23,25,4,52,52,92)
now isn't that queer?

any body got a solution?
help is GREATLY appreciated!

New Array With All Alphabet And Numbers
Hi,
I am working on creating new array with all alphabet and numbers. Is it possible to do this in one line. I will use it to pick one on rendom turn over.

selectone = new Array (alphabet);


or is it better to stick with old fashion hand working.

selectone = new Array ("A", "B", ...etc, );

btw. i am doing this with flash5 but if it is possible in flash mx let me know.

thx,
m.

Totalling Numbers From An Array.
I have an array that records a series of numbers, but I want them to be totalled, how would you recomend doing this?

How To Put Unique (different) Numbers To Array
Hi!

Please help me, guys. I have an array of lenght 3, let's call it "myArray". Now I want to generate 3 numbers with Math.round(Math.random()*2) and put them to myArray but no number should repeat in it. So in case Math.round(Math.random()*2) would generate a number which is already in myArray, it wouldn't put it there, it would generate an other number and compare it with the numbers in array again.

Thank you for any advice or ideas!

Array Index Numbers
I'm duplicating a series of movieClips along with a for loop that is populating an array with the instance names of these movieClips.

Is there a way to trace just the index numbers of the array?

I tried a clipEvent function on the actual movieClip that calls for the i variable in the for loop, but it's only returning the last number in the for loop for all the movieClip duplicates.

Random Numbers From 0 - 9 In Array
What should I do so I end up with an array of random numbers like

[2, 6, 4, 9, 0, 3, 7, 8, 1, 5]
[3, 5, 8, 1, 9, 0, 6, 7, 2, 4]

I'm thinking like starting with an ordered array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

randomly pick one by one out
[0, 1, 2, 3, 4, 5, 6, 8, 9] -> [7]
[0, 1, 3, 4, 5, 6, 8, 9] -> [7, 2]
[0, 1, 3, 4, 5, 6, 8] -> [7, 2, 9]
[0, 1, 3, 5, 6, 8] -> [7, 2, 9, 4]

Until I end up with something randomly sequenced.

How can that be done? Or is there a better way?

Help With Array And Random Numbers
Hi, I wanna be able to populate an array of 25 element with a random number between 0 and 4.

But I cant have more than 5 elements of the array with the same generated number.

Example, I need an array like this:

0 2 0 1 4
3 1 0 2 2
4 0 4 3 1
4 1 0 2 3
3 1 2 4 3

5 element with 0
5 element with 1
5 element with 2
5 element with 3
5 element with 4

Wich is the easiest way ?

AS3: How To Sort An Array Of Numbers
hi everybody.


I'd like any kind of tips on how to use ActionScript3 to sort an Array of Numbers.
i. e:

Code:
var _unsortedArray:Array = [34000, 77800, 12300, 11000, 21600, 33120, 18190, 43090];
any nice tips?

thanks
felisan

Find Two Numbers In An Array That Sum To A Particular Value
So, while working on my Dictionary/Hashtable tutorial, I decided to create a more interesting example that many of you may have encountered. Basically, given a huge list of numbers, the goal is to find two numbers from that list that sum up to a particular value.

I provide an example and a more elaborate description in this link. The code for it is:

Code:
//Declaring a Dictionary
Dictionary<int, int> numberHash = new Dictionary<int, int>();

//Collection of Integers
int[] values = { 144, 29, 46, 55, 33, 64, 174, 144, 168, 129, 73, 186, 24, 163, 3, 165, 160, 79, 39, 3, 81, 175, 183, 175, 15, 150, 177, 191, 29, 106, 104, 56, 58, 85, 172, 72, 119, 192, 134, 11, 10, 54, 34, 27, 194, 182, 71, 183, 132, 147, 23, 78, 70, 13, 144, 93, 104, 177, 181, 62, 155, 26, 50, 172, 158, 17, 139, 156, 105, 26, 162, 15, 65, 30, 174, 62, 175, 182, 121, 56, 23, 77, 179, 161, 168, 36, 25, 46, 137, 178, 51, 21, 65, 41, 78, 71, 196, 142, 78, 33, 130, 81, 55, 15, 131, 145, 135, 99, 116, 104, 20, 6, 22, 201, 135, 29, 148, 71, 110, 20, 104, 89, 105, 1, 10, 9, 53, 92, 75, 112, 161, 106, 196, 60, 163, 102, 109, 182, 148, 56, 88, 47, 151, 22, 119, 97, 163, 77, 126, 16, 151, 112, 143, 15, 76, 133, 124, 49, 114, 36, 183, 64, 4, 129, 201, 197, 161, 46, 103, 36, 58, 2, 78, 199, 113, 97, 53, 149, 60, 78, 63, 50, 152, 150, 140, 113, 101, 85, 80, 123, 186, 78, 95, 105, 195, 74, 121, 44, 40, 94, 149, 34, 74, 78, 28, 166, 126, 132, 51, 15, 200, 147, 77, 170, 171, 67, 67, 52, 57, 198, 186, 152, 69, 43, 194, 12, 37, 157, 144, 128, 153, 168, 130, 121, 186, 200, 195, 192, 162, 180, 95, 94, 24, 39, 37, 131, 177, 103, 106, 62, 28, 110, 145, 67, 99, 98, 137, 56, 26, 10, 56, 152, 36, 195, 150, 3, 87, 193, 16, 128, 186, 67, 122, 196, 162, 24, 56, 12, 2, 160, 190, 84, 17, 13, 112, 11, 200, 177, 120, 26, 33, 23, 11, 176, 7, 160, 49, 177, 92, 186, 176, 161, 175, 92, 30, 172, 186, 142, 145, 76, 44, 15, 171, 56, 158, 3, 9, 172, 92, 54, 101, 197, 158, 191, 102, 157, 32, 193, 156, 164, 74, 10, 106, 91, 176, 32, 132, 69, 197, 188, 184, 109, 5, 160, 200, 116, 55, 93, 143, 26, 82, 140, 52, 176, 120, 198, 178, 125, 122, 201, 44, 56, 96, 96, 29, 175, 156, 113, 17, 18, 70, 158, 159, 193, 162, 153, 40, 67, 170, 177, 182, 40, 78, 192, 173, 151, 55, 110, 142, 155, 56, 1, 134, 134, 50, 189, 105, 158, 34, 51, 17, 98, 131, 158, 89, 57, 158, 82, 112, 95, 149, 78, 60, 31, 144, 27, 94, 4, 45, 88, 152, 157, 82, 188, 73, 67, 198, 199, 198, 123, 201, 20, 171, 8, 115, 66, 144, 190, 126, 108, 5, 12, 14, 147, 35, 52, 139, 108, 57, 2, 128, 54, 157, 145, 75, 34, 26, 63, 201, 124, 198, 42, 109, 153, 177, 47, 173, 150, 3, 143, 198, 167, 110, 66, 20, 151, 147, 115, 108, 191, 142, 123, 169, 17, 127, 197, 86, 39, 144, 10, 165, 36, 151, 179, 185, 75, 39, 86, 194, 3 };

//Value to Guess
Random randomNum = new Random();
int x = randomNum.Next(10, 200);

//Trying to find two numbers that, when added, equal the sum
for (int i = 0; i < values.Length; i++)
{
int currValue = values[i];
if (!numberHash.ContainsKey(currValue)) {
int diffValue = x - currValue;
numberHash.Add(currValue, diffValue);
if (numberHash.ContainsKey(diffValue)) {
Console.WriteLine("Two values that add up to {0} are {1} and {2}", x, currValue, diffValue);
break;
}
}
}
As you can see, the code behind it is fairly simple. The ideas behind it have applications beyond this particular example, for there are many useful things you can do when storing/retriving data is really fast.

Just copy and paste that into a main method in VS2005 or another IDE and find out which two numbers in the array sum up to a value determined during runtime. You can also choose to run the attached file after extracting it. Whatever works

Cheers!
Kirupa

Random Numbers From 0-9 In Array
What should I do so I end up with an array of random numbers like

[2, 6, 4, 9, 0, 3, 7, 8, 1, 5]
[3, 5, 8, 1, 9, 0, 6, 7, 2, 4]

I'm thinking like starting with an ordered array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

randomly pick one by one out
[0, 1, 2, 3, 4, 5, 6, 8, 9] -> [7]
[0, 1, 3, 4, 5, 6, 8, 9] -> [7, 2]
[0, 1, 3, 4, 5, 6, 8] -> [7, 2, 9]
[0, 1, 3, 5, 6, 8] -> [7, 2, 9, 4]

Until I end up with something randomly sequenced.

How can that be done? Or is there a better way?

Add Array Values That Are Numbers
How do I add array values that are numbers when loaded dynamically via sql?

Example script doesn't calculate. Instead it just adds as though the elements of ycor array are string based. So ycor[0] = 2 and ycor[1] = 3 added equals 23 not 5. Of course these elements are being dynamically set via mysql db that generates a xml table. I've left out file locations and passwords for obvious reasons. Why are the elements being treated as strings?


Code:
var theXML:XML = new XML();
theXML.ignoreWhite = true;
theXML.onLoad = function(success:Boolean) {
if (success) {
main = [];
caption = [];
areaName = [];
areaType = [];
hyplnk = [];
ycor = [];
var nodes = this.firstChild;
var total = nodes.childNodes.length;
for(i=0;i<total;i++) {
main[i] = nodes.childNodes[i].attributes.main;
caption[i] = nodes.childNodes[i].attributes.caption;
areaName[i] = nodes.childNodes[i].attributes.areaName;
areaType[i] = nodes.childNodes[i].attributes.areaType;
hyplnk[i] = nodes.childNodes[i].attributes.hyplnk;
ycor[i] = nodes.childNodes[i].attributes.ycor;
}
images()
}
else {
statusArea.text = "Could not load SQL database" + '
'
}

}

func images(){
statusArea.text = ycor[0] + ycor[1] //<--- This doesn't give me 5 it gives 23

}
theXML.load("GetInfo.php");

PHP Code:



<?PHP$link = mysql_connect("location","user","pass");mysql_select_db("db");$query = 'SELECT * FROM table';$results = mysql_query($query);echo "<?xml version="1.0"?>
";echo "<menu>
";while($line = mysql_fetch_assoc($results)) {    echo "<subitem main='". $line["main"] . "' caption='". $line["caption"] . "' hyplnk='". $line["hyplnk"] . "' ycor='". $line["ycor"] . "'></subitem>
";    //echo "<subitem>" . $line["main"] . "</subitem>
";}echo "</menu>
";mysql_close($link);?>

Random Numbers From 0-9 In Array
What should I do so I end up with an array of random numbers like

[2, 6, 4, 9, 0, 3, 7, 8, 1, 5]
[3, 5, 8, 1, 9, 0, 6, 7, 2, 4]

I'm thinking like starting with an ordered array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

randomly pick one by one out
[0, 1, 2, 3, 4, 5, 6, 8, 9] -> [7]
[0, 1, 3, 4, 5, 6, 8, 9] -> [7, 2]
[0, 1, 3, 4, 5, 6, 8] -> [7, 2, 9]
[0, 1, 3, 5, 6, 8] -> [7, 2, 9, 4]

Until I end up with something randomly sequenced.

How can that be done? Or is there a better way?

AS3: How To Sort An Array Of Numbers
hi everybody.


I'd like any kind of tips on how to use ActionScript3 to sort an Array of Numbers.
i. e:

Code:
var _unsortedArray:Array = [34000, 77800, 12300, 11000, 21600, 33120, 18190, 43090];
any nice tips?

thanks
felisan

Sort Array Of Numbers
I created this script to test.

Objective: I wanted to find out which variable had the highest value and return the name of that variable.

Problem: The functions work BUT it treats the variable values as if it were like strings. For example if we had 3 numbers to sort... 9, 23,78

Then the sorted result would be 9,78,23.
The problem is that it reads the numbers beginning with the first digit. So instead of 78,23,9 like what I expect the array.sort() sees 9,7,2 the first digits of the number. Only when the numbers have identitcal first digits does it go on to the second digits to sort. ie 34,38,35, 7 would sort to 7,38,35,34

Is there an easy answer to solve this ?
(or do I have to write an extra function to code around this ? )


Code:
function generatenum(){
a=Math.round(Math.random()*30);
b=Math.round(Math.random()*50);
c=Math.round(Math.random()*50);
d=Math.round(Math.random()*20);
e=Math.round(Math.random()*100);
testarray1=new Array(a,b,c,d,e);
}

this.onMouseDown=function(){
testarray1=testarray1.sort();
testarray1=testarray1.reverse();
switch(testarray1[0]){
case a:
winner="a";
break;
case b:
winner="b";
break;
case c:
winner="c";
break;
case d:
winner="d";
break;
case e:
winner="e";
break;
}
}
this.onMouseUp=function(){
generatenum();
}

AS3: How To Sort An Array Of Numbers
hi everybody.


I'd like any kind of tips on how to use ActionScript3 to sort an Array of Numbers.
i. e:
Code:

var _unsortedArray:Array = [34000, 77800, 12300, 11000, 21600, 33120, 18190, 43090];

any nice tips?

thanks
felisan

Averaging Set Of Numbers In An Array
hi,

say, i got an array; it consists of numbers. i want to average those numbers in sets of five or maybe ten.

for instance;
index 0, 1, 2, 3, 4 are one group and yield one average, 5, 6, 7, 8, 9 make up another group and yield another average and it goes on like this.

i went into the help, but could not dig anything useful.

Comparing Array Element Numbers
Does anyone out there know how to sort by element number of an array? While the question might seem strange, the purpose is to compare element numbers of one array with those of another containing the same items in a different order. Any ideas, anyone?

Problem : Array.sort() With Numbers
Hi.
Can someone tell me how the Numbers are sorted in ActionScript

//an exemple :
A_TEST1 = new Array(234, 89, 1, 10, 123);
A_TEST1.sort();
trace(A_TEST1);

// return : 1,10,123,234,89

That' means that ActionScript considers 10 as 1+0, and not 10.
This is a big problem.
Is anybody has a solution to avoid this problem ?

thanks.

Random Array Of Numbers - No Repeats
hi, I want to create a random array of 20 numbers (1-20) where every number is different.

I have the following so far:

item = 0;
number_limit = 20;

function insertRandomNumber(){
random_numbers[item] = random(number_limit)+1;
item++;
}

this function is called 20 times on the timeline, but my problem is I can't figure out a way of having it so that numbers aren't repeated in the array. Any help would be appreciated.

Placing Random Numbers Into An Array
Hi!

I am building a quiz type piece where I have 7 frames, but I only want 5 of those frames to show up each time a user comes to the site.

I've written psuedo code for myself in an attempt to understand what the actionscript will need to do.

"Take 7 numbers and choose 5 of those numbers randomly (the numbers can not repeat). Place them into an array in the order they are chosen. Play each number in their order in the array. After all 5 numbers have been played, go to frame 8"

ok, so now, if my psuedo code is correct, I need to translate it to actionscript:

code:
numbers = [1,2,3,4,5,6,7];
randomNumber = numbers[Math.floor(Math.random() *6)];

Ok, I can tell I already have a problem here. This only gives me 1 number. I need 5, and 5 numbers that don't repeat. So...I guess I'll leave this as my first question, before I worry about the rest.

Does anyone have a suggestion for me?

Thanks!

Array Question (Order Of Numbers)
Hi,

I created an array that contains a set of variables.
The variables in the array are numbers generated by simple math operations. I need to arrange the numbers in ascending order and then have them appear in a dynamic text field called order. This is the code I'm using:

answerArray = [aone, atwo, athree, afour, afive];
answerArray.sort();
order = answerArray;

When the numbers in the array are all above 9 such as [12, 18, 15, 14, 19], or all below 10, they are listed in the correct order. But, when the numbers in the array are mixed single and double digits [5, 17, 3, 22, 4], the order is 17, 22, 3, 4, 5.

What can I do to get the correct order (3, 4, 5, 17, 22)?

Thanks.

Populating Multidimensional Array With Numbers
Hi all,

I want to create an array that holds all x and y coordinates of a 168 x 168 grid divided by 4 pixels. So I should end up with someting like this:
[0,0], [0,4], [0,8], [0,12] ... etc.
[4,0], [4,4], [4,8], [4,12] ... etc.
[8,0], [8,4], [8,8], [8,12] ... etc.
... etc.
I've managed to create an x and an y array like this:

Code:
x_array = new Array();
y_array = new Array();
i = 0;
j = 0;
while(i<=(168/4)){
while (j<=168){
x_array.push(j);
y_array.push(j);
//trace("j= "+j);
j = j+4;
}
//trace ("i="+i);
i++
}
This just generates two one dimensional arrays looking like this: 0,4,8,12,16,20 etc. upto 168. But now they need to be put together in one big array...? Is this the way to do it or do you code guru's have other suggestions?

Thanks very much for you help, Danielle.

Converting Elements In Array To Numbers
I've been using arrays to store data throughout my FLA, but now when I want to add up a bunch and spit out a sum for total, I'm getting NaN errors. Please help. Here's the code:


ActionScript Code:
_root.totalQuantity = (drug01[2] + drug02[2] + drug03[2] + drug04[2] + drug05[2]);

I want it to LITERALLY add those numbers together. What's the deal?

Not Allowing Duplicate Numbers In An Array
I have an array where the user enters 6 numbers and then presses a button. Is it possible for an error message to come up if there is a number repreated?

Checking Array For Duplicate Numbers
Hi, I have an array of random generated numbers between 0-31 and I want to check for duplicate entries before I populate my tex fields with those numbers:
Tha code I have looks like:


var numbers = new Array();
for(var i=0;i<8;i++)
{
a = random(32);
b = parseInt(a);
numbers.push(b);

_root["tagText" + i].text = numbers[i];
}

My text fields are tagText0, tagText1 and so on till tagText7.
This works well, but I get duplicate numbers, and I want unique numbers.
I tried loops like:

for (var j = 0; j<8; j++)
{
for (var k = 0; k<8; k++)
{
if (numbers[j] == numbers[k])
{
numbers[j] = random(32);
}
}
}


before populating my text fields but it didn't work
Any ideas anyone?

Thanks a lot

Array With Unique Random Numbers
Hi,
I'm trying to come up with a function that will populate an array with 4 unique random numbers. I'm stuck on pushing unique numbers, the attached code creates the array, but sometimes there are duplicate numbers. I've tried a for staement inside the for stement to test for duplicates but get lost. Is there an easy way to do this? Thanks.











Attach Code

var myAreaArray:Array = new Array();

function randPush(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}

function fillArray():Void {
for (var i:Number = 0; i<=3; i++) {//repeat 4 times
var arrayn:Number = randPush(1, 8);//The random number and range. The range in this case 1 thru 8
var pushed:Object = myAreaArray.push(arrayn);
}
}

fillArray();
trace(myAreaArray); //might return something like 7,4,1,7

How Do I Add A List Of Numbers Stored In An Array
How do I add a list of numbers stored in an array? The code I have is showing ‘NaN’ when I try to add the second item in each element of the array:

var aItemPrices:Array = new Array(["item1_mc", 10], ["item 2_mc", 20], ["item 3_mc", 30]);
var totalPrice:Number;
for (i=0; i<aItemPrices.length; i++) {
//the following line traces 'NaN'
totalPrice += aItemPrices[1];
trace("totalPrice: "+ totalPrice);
}

Array Returning Non-repeated Numbers. How?
Hello there,

Simple. Take the array [4,6,6,7,8,8] for example.
we have the number 6 and 8 twice.

Isn't there a method to return this array like: [4,6,7,8] ?
or, how can I push this number into the array only if they are not pushed yet?
I tryed to make a loop with condition to check if the numbers was already there, but I had no bliss.

this is my code now:


HTML Code:
meses = [];
arquivos = xmlData.firstChild.childNodes[0];
//populando array meses
for (i=0; i<arquivos.childNodes.length; i++) {
mes = mesNome(arquivos.childNodes[i].attributes.mes);
meses.push(mes); //<<<< here I think its the problem
}
I think the code can't help, but, there it is. This array "meses" (months, if you prefer), returns that example I told you about: [4,6,6,7,8,8], but I needed it with unique numbers.

Some advices please
thanks a lot,
Deh

Trouble Adding Numbers In Array
As an excercise, I'm trying to create a class that will take the average value of numbers in an array.
I'm stuck on adding the values of the array elements. I keep getting "NaN" for the total. Below is my code.


ActionScript Code:
private function getTotal ():Number
    {
        var total:Number;
        for (var i = 0; i<numArray.length; i++)
        {
            total += Number(numArray[i]);
        }
        trace("total= "+total);
        return (total);
    }

Using Array To Include A Pattern Of Numbers Within An If Statement?
Hi,
I need a shortcut to say (_currentframe == 33 or 63 or 93 or 123, etc)
Also, using 'or' or '||' doesnt work. (i.e. (_currentframe ==(33||63||93||etc)))
I believe the way to do this is with an array. Would an array fit into this if statement? And How would it be incorporated? Where would the array AS be located? on the MC within the onClipEvent?

This AS works perfectly:
onClipEvent (enterFrame) {
if ((this._currentframe>_root.lastframe) || (_currentframe == 33)) {
_root.playstatus = "playing";
} else {
_root.playstatus = "stopped";
}
_root.lastframe = this._currentframe;
}

Within this MC i am using a custom loop function.
The loop function:
function loop (looptime) {
if ((autoplay == "yes") and (this.loopvar<=looptime)) {
this.loopvar++;
gotoAndPlay (_currentframe-22);
_root.looptime = looptime;
_root.loopvar = (loopvar-1);
_root.loopstatus = "yes";
}
}

View the file:
http://stimuli.steeped.net/matt/misc/coco/3.html
*note: press '1' within the flash to view my custom debugger that lists vars. Then view the presentation.

Thanks in advance!

Numbers Imported As A Variable... Transfered To An Array?
ok this may get a little tricky... I am importing information from a domino server to my flash... here is a list of numbers similar to what will be imported....

0, 0, 1, 1, 2, 2, 5, 3, 4, 4, 0, 5, 4, 0, 0, 1, 4, 2, 2, 3, 0, 4, 0, 5, 5, 0, 1, 1, 5, 2, 0, 3, 2, 4, 4, 5, 1, 0, 1, 1, 0, 2, 1, 3, 4, 4, 5, 5, 2, 0, 0, 1, 0, 2, 1, 3, 2, 4, 2, 5, 0, 0, 1, 1, 2, 2, 1, 3, 1, 4, 0, 5


is there any way to import that into an array???

It gets trasfered right now as varialble such as

imported_numbers = 0, 0, 1, 1, 2, 2, 5, 3, 4, 4, 0, 5, 4, 0, 0, 1, 4, 2, 2, 3, 0, 4, 0, 5, 5, 0, 1, 1, 5, 2, 0, 3, 2, 4, 4, 5, 1, 0, 1, 1, 0, 2, 1, 3, 4, 4, 5, 5, 2, 0, 0, 1, 0, 2, 1, 3, 2, 4, 2, 5, 0, 0, 1, 1, 2, 2, 1, 3, 1, 4, 0, 5


but i want to make that work like an array... and

TestingAttempt = new Array(imported_numbers);

does not seem to work... any suggestions

How Can I Generate An Array Of *exclusive* Random Numbers?
I have been trying to write some code that will produce a list of *exclusive* random numbers between 1 –10.

What seemed very easy has actually taxed me to death!

I have started by setting up a standard “for” loop to push random numbers (generated by Math.random() ) into an array. I then set up another “for loop” within the first to go through all the indexes in the holding array & if the number at that index was not = to the random number generated, push that number onto the end of the array to give an array of exclusive numbers. Problem I have, apart from the fact that the above is about as much good as a chocolate teapot, is how do I know how many times to loop the initial for loop – I can’t tell how long it will take to generate a list of totally exclusive random numbers. If I tell it to loop 10 times it might just come up with 5 exclusive numbers – 3,8,6,4,4,5,3,3,9,1 – only 8,6,5,9,1 all the rest are duplicated.

Any ideas or better ways to achieve this?

Writing An Array Of Numbers To A Shared Object
My first question is hopefully easy: How to write an array of 0's (comma delimited) to a Shared Object? Something like...


Code:
completePageSO = SharedObject.getLocal("CompletePage", "/");
var temp:Array = new Array;
for (var j:Number = 0; j < 43; j++) {
temp.push[j];
if (j >= 42) {
completePageSO.data.completionArr = temp;
completePageSO.flush();
completePageSO.close();
}
}
The array doesn't work, but hopefully someone will get the idea.

Dynamic Display Numbers, Hyphens, Periods, From An Array?
I have this dynamic menu I've been using but I don't know how to get characters that aren't the letters of the alphabet to display. I need to display numbers, hyphens, and periods. How do I do that? Let me know if you need an .fla.

thx

Past Frame Numbers Stored In Array For 'previous' Button
I have an swf with buttons that load to different pages (frames of the swf), and what I'd like to do, each time the frame is changed, is push the current frame into an array so that on a couple of 'previous' and 'next' buttons I can change to pages already visited and back forward again if the user chooses

it's a little tricky for me, considering that I don't want to keep pushing the same pages into the array if someone goes back and forth a few times, so maybe some additional code would be needed to check and see if the frame number is already in the array, and if so, ignore the push code?

I don't know. before I get started, does this approach sound like the simplest/best?

How Can I Check If A Certain Val Is An Array?
say i hava var called
myVar
how can i know if its an array at the moment or not?how can i check it?
thanks in advance
peleg

Check Array For Value.
How can I check to see if a number (or any value) is in a string or array?

For example, I'd like to see if the number 3 in the array [1,4,5,6,7,88,3,9]

Thank you.

Check Array For Value.
How can I check to see if a number (or any value) is in a string or array?

For example, I'd like to see if the number 3 in the array [1,4,5,6,7,88,3,9]

Thank you.

Array Check ?
is there a way to check something like this
i need to verify all arrays from array[0] to array[26]
are different or not ??
is this posible ??

Regards

Check Array For Value
Another Q,

I need to check an array to see if it contains a value. I don't need to know where it's at or anything, just wheather its there.

Ideas?

Check If The Value Is In The Array
Hi guys!

Does anybody know, how can I check if the value is in the Array?

Code:
var myArray:Array = Array("firstElement", "secondElement", "thirdElement");
if( myArray.isInArray("firstElement")){
trace("true");
} else {
trace("false");
}

Check Against Array
hi, is there any way to check against all values in an array. what i am doing is making a random engine of 10 items, i don't want any of the ten to come up again, or if they do to have flash keep producing random numbers until a new one comes up.

any help is appreciated.

Check If Loaded Array
I'll just say up front that i have no experience creating arrays. I'm wondering if it's possible, (with an array) to 'record' where people have gone in my site. That way if they've already been somewhere, (specifically if a picture has been viewed previously) it'll show up right away.

currently on my site when you click on the photos in the gallery after they've loaded the preloader still pops up for a fraction of a second when you go to view them again. i want to get rid of that.

if anyone has any bright ideas, that would be awesome.

many thanks,
_greg

Check Array Do Action To All Except One
Hi,
I have 5 instances of a mc.
It contains a button.
They are named MenuTabA, MenuTabB etc to E
When a button is clicked I want to make all the ones except the one that was actually clicked go to a frame label.

How do I loop through an array of all their names when the button is clicked performing an action but skip the one which was actually clicked?
thanks - using flash MX
mark

Copyright © 2005-08 www.BigResource.com, All rights reserved