Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 2 of 2

Thread: Is this possible? (rollover random sound sequence)

  1. #1

    Is 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.

  2. #2
    1,391
    posts
    Registered User
    hello - 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:
    Code:
    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;
    }
    in the above, each element in the array is a Class - or the linkage id of the Sound in the Lib that you define

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012