Flasher Archive

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


Subject: Re: FLASH: Arrays
From: unique
Date: Wed, 9 Feb 2000 12:24:32 GMT

Fletch <Fletchatfree [dot] fr> anointed the exact instant of 2000.02.09.08.09 with this
juicy flow:

> can u explain a little bit more (for non-english people), please ?
> with hope to help you.

I've posted this on another email list a coupla times, so, cut and paste, here
ya go:

----------

Flash does not feature *true arrays*.

First, read this quote from

http://support.baynetworks.com/library/tpubs/html/router/soft1100/114089A/4089A_15.HTM

"A true array is a set of consecutive memory locations used to store data. Each
item in the array is called an element. An element is a variable. To reference
an element of an array, you use a number called the index. [My note: the names
of such variables in such a set might be written a(1), a(2), a(3), etc.]

"In a pseudo-variable array, the elements (variables) are not in consecutive
memory locations. To create a pseudo-array, use variable names that end in
numbers (for example, a1, a2, and a3)."

So, if you simply want a one-dimensional pseudo-variable array, you can, as
stated above, simply name your variables a1, a2, etc. Actionscript and its
syntax will allow you to generate a pseudo-variable whose index you don't know
but will calculate within the actionscripting of the movie, or obtain from
"outside" data and/or input. (E.g., perform some calculation to arrive at, say,
5, then use syntax properly to combine the calculated value with the letter "a"
to end up with a variable name "a5".

It's not much more than a logical extension to figure out how to do arrays of
two or more dimensions. (Instead of just a one-column "array", envision, say, a
two-dimensional array of data that has rows and columns -- for example, a times
table. The elements of a 3x2 "true" array, for example, might be named:

a(1,1) a(2,1) a(3,1)
a(1,2) a(2,2) a(3,2)

Now, for this small a table of data, with only 2 dimensions, your solution is
simple: name your variables

a11 a21 a31
a12 a22 a32

Throw a little "10x+y" math into your calculations, and you're home free.

( index = 10*colnumber + rownumber )

*However*:

For a table that is either larger, and/or three-dimensional (picture a cube) or
even greater-dimensional (good luck picturing! (hint: 4-D is a row of cubes, 5-D
is a table of cubes, 6-D is a cube of cubes, etc.)), extra digits wanna come in
and it gets unwieldly.

If you have, say, a 99x99 table, you could go with "a0101, a0201, etc". (But
don't forget, when doing your calculations and implementing proper syntax, you
will have to add the *leading zeroes*!)

Long story short, there's a second way ... I'll leave out the picky details, and
what I'll say here applies to >2-D arrays as well.

Let's keep it simple by using the 3x2 table above.

Instead of the above calculation that I typed for "index" values, you use this
one:

( index = c*(rownumber-1) + colnumber , where "c" equals the number of columns
-- i.e., "c" is the maximum colnumber )

Now, the formula's less tidy, but the indexes look ssssssssssssso-pretty:

a1 a2 a3
a4 a5 a6

Which of the two methods you choose often depends mostly on which kinda "table"
you prefer to look at and think about: the first, where you can see the
subindexes (rownumber, colnumber, etc.) just by inspecting the (longer) variable
indexes; or, the second, where every variable has a sequentially determined
index (which *can*, BTW, *also* be retrofitted to its component "true array"
indexes, with another (actually, the same! :-) ) formula.

So there ya go, pseudo-variable arrays in a nutshell, for the Flash user. (This
is just a beginner's intro, though!)

Consider, for instance, that a true array number can have one or more indexes
that is equal to zero, *and* that, the consideration can continue to move into
the realm of negative numbers! SO, voila, we suddenly find ourselves able to
specify our point in space, relative to an arbitrary origin of a 3-D Cartesian
coordinate system ... ah, trigonometry, and even calculus ... I'm in Flash Math
Heaven!

----------

See ya,

Ken Sherwood

--

"Ever since I got the first Beta Demo of Flash when it
came out over three years ago I somehow feel I am dealing
more and more with Popcorn Vendors and Organ Grinders!"

-- Some Flash Hot Shot on Some Flash Email List Somewhere



flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flashforward2000 and The Flash Film Festival
"The World�s Premier Flash Solutions Conference and Expo"
March 27-29, Nob Hill Masonic Center, San Francisco, California

-Register before Feb 25 and save $200!!-- www.flashforward2000.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com


Replies
  Re: FLASH: Arrays, Fletch

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