Hello Community!
Starting to get my AS3 feet wet and have not been able to
figure out a tried and true method I usually use for handling a
series of similarly named buttons.
Scenario: I have a series of, say, 10 buttons (actually
MovieClips that behave as buttons) that are named [selector0,
selector1, ..., selector9] which all call the same function but
pass a different variable "ivar" that is the same value of the
number part of the name of that button. For example, if I click on
the "selector3" button the "ivar = 3" is passed to the function,
etc..
This is the AS2 code that I have used faithfully in this
scenario which enable me to write a few line of codes to control
all 10 of the buttons at the same time instead of having to write
10 seperate ".onRelease = function..." is as follows (under //OLD
SCHOOL):
Now, I have tried to make this scenario work in AS3 with the
following (under //NEWSCHOOL): but it does not work. I think that
the problem is centered on the fact that I only pass the MouseEvent
to the function but not the ivar variable. I have tried to pass two
arguments to the function, but with strange error messages.
I suspect that since AS3 is more robust that there is a super
elegant way to solve the problem that I am having: controlling a
large series of similarly named, indexed buttons with one loop
instead of needing to write out separate code for each button.
Any feedback would be greatly appreciated.
-john