Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: RE: [flasher] Array problem
From: Paul Willoughby
Date: Thu, 08 Mar 2001 17:21:52 -0000

Couple of things you should look at.

1. An array is an object so it's name shouldn't be in quotes, and [] is the
array access operator. Square is the array object and count is a variable
you're using to access the array. So your if statement should be:

if (square[count]) == "A1")

2. Movie clips can also be targeted using the array access operator. Instead
of your set property statement try:
_root["square" add count]._y = whatever

If 'count' is 0, this would target movieclip 'square0'. If you don't want to
use the actual count variable, but use it as a reference to an item in the
square array try:

_root["square" add square[count]]._y = whatever

If count is 0, this would target movieclip 'squareA1'. If the clips are
actually called A1, A2 etc. this might work:

_root[square[count]]._y = whatever.

IMHO I don't see the point of storing the information in the array if it's
sequential. You can just increment the count and make a movieclip name by
adding it to the string.

hth

paul


> -----Original Message-----
> From: Ed Harvey [eharveyatiddnet [dot] com (mailto:eharveyatiddnet [dot] com)]
> Sent: 08 March 2001 15:34
> To: flasher from chinwag
> Subject: [flasher] Array problem
>
>
> I'm having trouble understanding how to use arrays. What I
> want to do is
> take one of the symbol from the array and set it's position
> on the screen.
> Then move onto the next one. When I trace the Array, I get
> the entire string
> when I want just one. This is the script I am using.
>
> square = new Array(6);
> square[0] = "A1";
> square[1] = "A2";
> square[2] = "A3";
> square[3] = "A4";
> square[4] = "A5";
> square[5] = "A6";
> count = 0;
> pos = pos+10;
> while (count<=4) {
> trace ("count =" add count);
> trace ("pos =" add pos);
> trace ("square5=" add square add [count]);
> width = getProperty(eval("square" add [count]), _width)+10;
> if (eval("square" add [count]) == "A1") {
> setProperty (eval("square" add [count]), _y, 0);
> setProperty (eval("square" add [count]), _x, pos);
> } else {
> setProperty (eval("square" add [count]), _y, 0);
> setProperty (eval("square" add [count]), _x, pos);
> pos = getProperty(eval("square" add [count]), _x);
> }
> count = count+1;
> }
>
> Ed



[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]