This content has been marked as final. Show 9 replies
> var mySounds:Array = [sound0, sound1, sound2, sound3];
Use the AS1 way to assign an array, like this...
var mySounds = new Array (sound0, sound1, sound2, sound3);
Please forget the last post since my array was still not correctly syntaxed.
The latest corrective outputs: [object Object],[object Object],[object Object],[object Object]
And still no sounds.
Latest file here:
"Detonate 2004" <email@example.com> wrote in message news:firstname.lastname@example.org...
> Please forget the last post since my array was still not correctly syntaxed.
> The latest corrective outputs: [object Object],[object Object],[object
> Object],[object Object]
> And still no sounds.
> Latest file here:
I can't look at the fla because of my old Flash version but I looked at your posted code again.
Do you need all that array stuff for anything? I mean, if all you want to do is play a random song every N seconds you can do it
with just a few lines of code..
var snd = new Sound();
var g = random(2) + 1; // 1, 2 or 3
snd.attachSound("s"+g); // s1, s2 or s3
randomSound(); // start the first song now
id = setInterval(randomSound, 10000); // change songs every 10 seconds
Make sure you have 'linkage' names for your 3 songs (not library names)
Your original code did play 1 song every 1 second (just makes a popping sound when changing that fast) so I suspect that your
linkage names were missing.
I wouldn't use a recursive coding like that though. (a function that calls itself)
the code in your first message is going to fail unless a randomArray() method is defined and as tralfaz pointed out, there's no need for more than one sound object.
Sugg. code works A-OK! Thanks a lot guys.
Unbelievable the amouth of useless lines I had in my 1st attempt.
Currently looking to implement it within a MouseDown action.
The mousedown action is called within a movie clip on stage.
Ex: Only start playing if the mouse is pressed down.
Thanks again for your time!
you're welcome. and just call randomSound() onMouseDown() if you want to execute that code whenever the left mouse button is pressed.
very happy, it worked pefectly with external sound sources too =)