all groups > flash actionscript > march 2005 >
You're in the

flash actionscript

group:

Arrays and Actionscript


Arrays and Actionscript kickflash
3/3/2005 10:25:16 PM
flash actionscript:
Hello, I am trying set up a routine that plays random sounds. I have a movie
clip with 1 layer on it called soundmaster_mc. Inside of this clip, I have 4
frames. Each frame contains another movie clip called s1, s2, etc. In each of
these, I have a sound. My question is: Can I put Actionscript commands in an
array? For example: myArray = new Array() ; myArray[0] = this.s1.play() ;
myArray[1] = this.s2.play() ; I haven't tried it yet since I felt that I need
to ask other if I could or not. Has anyone done this?:confused;
Re: Arrays and Actionscript metric152
3/3/2005 10:40:00 PM
Re: Arrays and Actionscript NSurveyor
3/4/2005 12:14:22 AM
OR:

myArray[0] = this.s1.play;
myArray[1] = this.s2.play;

Re: Arrays and Actionscript semans
3/4/2005 3:42:56 AM
I agree with metric152.
Re: Arrays and Actionscript Jeckyl
3/4/2005 10:54:02 AM
instead

myArray[0] = this.s1;
myArray[1] = this.s2;

then use

myArray[xxx].play();

-OR-

myArray[0] = function() { this.s1.play(); }
myArray[1] = function() { this.s2.play(); }

then use

myArray[xxx]();


--
All the best,
Jeckyl

Re: Arrays and Actionscript Jeckyl
3/4/2005 11:34:13 AM
[quoted text, click to view]

yeup .. that too .. to misquote Shakespeare.. "How do I call thee, let me
count arrays"
--
All the best,
Jeckyl

Re: Arrays and Actionscript Jeckyl
3/4/2005 2:52:37 PM
storing names is not as good as storing the reference .. especially if you
are going to play it more than once. Put as much in there as possible (eg
like nsurveyor's suggestion) .. then most of the work is already done when
the array is set up, and you can directly play it after that. And the code
with eval's etc is pretty ugly as well.
--
All the best,
Jeckyl

AddThis Social Bookmark Button