Array

hi there…

I’m checking out arrays because I want to learn to use them, but also because I need to. Which means I will have to…

I’ve read this: http://www.flashkit.com/tutorials/Actionscripting/Expert/FlashGur-FlashGur-582/more3.php

but it got me in a knot.

There’s no problem in creating things in an array, nor in displaying it’s length…

but my problem is this:
I want to write an if-function that checks wether or not an item is in my array… and I’m totally of the hook with the sintax…

and once this works, I want to know how to dinamically add values to my array, guess I’m gonna check that one allready out, question of not losing to much time…

friendly greetings,
robin

p.s. now as.org is down, I’m going to be bugging all of you with my annoying things… have merci… :pope: :wink:

im not quite sure what you wanted but this just searches the array for a string value and returns the position of the value:

[AS]
myarray = new array();
myarray[0] = “apple”;
myarray[1] = “orange”;
myarray[2] = “pear”;
for (i=0; i<3; i++) {
if (myarray* == “pear”) {
trace("position of pear is "+i);
}

}
[/AS]
If theres any more needed explaination or not the right thing just ask away

you might want to use myarray.length instead of hardcoding the 3… just so you know its accurate :wink:

works like a charm mate!

thanks a lot

r:eye: bin

héhé, thx senocular, made that change also :wink:

but I’m very very happy someone showed me the code with the syntax.

I fully understand, and hope I’m fully capable to change it, but coming up with it myself would have been a struggle I’m glad I don’t have to do :D:rambo:

robin

so I bounced into the next problem:

first I’ll post my code… so you guys can point me possible mistakes out…:

[AS]_root.index=0;
_root.myArray=[“naam1”];
arrayLength=_root.myArray.length;

function holdUp(){

_root.lightUp="naam"+_root.index;
checkUp=_root.lightUp;

_root.scroll.knoppen[checkUp].gotoAndStop("over");

for (i=0; i&lt;arrayLength; i++) {
	
	if (_root.myArray* == checkUp) {
	
		trace(_root.myArray*);
	
	}else{
		
		_root.myArray.push(checkUp);
		arrayLength=_root.myArray.length;
		trace(_root.myArray);
	
	}
}

}

[/AS]

I hope you guys see what I’m trying to do here:

I’ve got these 70 buttons, and when clicked I want them to stay to a red color (the over frame) but when another is clicked I want the ones that are red to become darker red (the visited frame)

so I thought of putting them in an array when clicked, and when another button is clicked, flash looks at all the buttons in the array, and tells them to go to the ‘visited’ frame…

the problem happens allready at the trace command.
when a value is added I get this…

naam1,naam3
naam3
naam1,naam3,naam4
naam1,naam3,naam4,naam4
naam4
naam4

these must be sending everything wrong…
or is my way of thinking incorrect too?

friendly greetings,
robin