Results 1 to 2 of 2
-
April 15th, 2012, 11:30 AM #11Registered User
postsIs this possible? (rollover random sound sequence)
Hi! I'm a beginner to Actionscript and was wondering if the following was possible for a project I'm working on; I would like a sequence of randomly-generated sounds from my library to play when the cursor rolls over the stage. Rather than one single random sound playing on rollover I would like a sequence of the sounds played one after the other continuously. Is this possible to achieve in Actionscript 3 and if so, how am I able to achieve this? If it is not possible, are there any similar effects? Thanks a lot.
-
April 15th, 2012, 01:28 PM #21,391Registered User
postshello - welcome
it certainly is possible - although it's a little difficult to tell from your description exactly what your looking for here, because of the conflicting terms 'random' and 'sequence'
but that said, you can use an array and an index to control the sequence, each time a sound is played, increment the index and play the 'next' sound in the array and recycle - something like this:
in the above, each element in the array is a Class - or the linkage id of the Sound in the Lib that you defineCode:var sounds:Array = [ Sound1, Sound2, Sound3, etc... ]; var index:int = 0; function rollover( e:MouseEvent ):void { new sounds[index]().play(); if(++index==sounds.length) index=0; }

Reply With Quote

Bookmarks