Flasher Archive

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


Subject: Re: flasher digest: March 24, 2001
From: Michael Rhodes
Date: Sun, 25 Mar 2001 16:11:49 -0000


> Subject: Variable Question
> From: Steve Gadlin <steveattypea [dot] net>
> Date: Fri, 23 Mar 2001 18:08:27 -0600
> X-Message-Number: 2
>
> I'm trying to declare a variable, but the variable name itself is dynamic,
> depending on the value of "n". For example, I want variables called x1, x2,
> x3, x4, etc... depending on n.
>
> Here's how I'm trying to do it:
>
> eval("x" add n "=" add _xmouse);
>
> That's giving me an error... saying that I'm missing a ' or a )... which
> makes no sense to me. Hmph!
>
> If someone could point me in the right direction, I'd be uberappreciative.
>
> Thanks a zillion!
>
> OH! Also, is it possible to have a Flash movie loop in one frame, or do you
> always have to have a 2nd frame with a gotoAndPlay(1) in it?
>
> Take care,
>
> Steev
> www.steveandstevedanceparty.com


Steev, you may want to try Arrays. These nifty lil' thangs allow for *one* name -- but it can
contain lots of individual data-bits. Sort of like a egg carton.

In your case you would want to declare your array:
----
myXmousePos = new Array;

//then you would fill the arrays with information:

myXmousePos[0] = _xmouse


---

It's important to realize that to either fill an array's "member" or to change it you have to use
the syntax: variableName[n] (where [n] is the member you want to work with). These members are
numbered *begining* with Zero (because computers do count Zero as being a value, just try to tell my
bank that!) and ending with the last member of the array. To get the number of members, just do:

howMany = arrayName.length;

and in the howMany variable you'll have the total number of members! Again, don't forget that
members are counted begining with Zero, so --

first member -- arrayName[0]
second member-- arrayName[1]

and so on.


For more info check out the Array(Object) entry in the ActionScript guide (Pg 214 in my book).


hth,

Mike Rhodes




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