A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [MX04] Generate a Random Sound

  1. #1
    Member
    Join Date
    May 2008
    Location
    Ireland
    Posts
    77

    [MX04] Generate a Random Sound

    Hi, I cant seem to find this simple code on the net. could someone post up the basic flash to generate a random sound when button is clicked.

    much appreciated Graham.

  2. #2
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Not too sure if this will work with MX04, but at least it may give you an idea on how to proceed. This just randomly selects a different frame from the mc "mc1" when the button is released. You could place a different sound at each frame. HTH. Cheers.

    PHP Code:
    btn1.onRelease = function() {
        
    mc1.gotoAndStop(getRandomLabel());
        
    //trace(getRandomLabel());
    };
    function 
    getRandomLabel():Number {
        var 
    labels:Array = new Array(1234);
        var 
    index:Number Math.floor(Math.random()*labels.length);
        return 
    labels[index];

    Last edited by Robb@exo; 08-20-2008 at 02:16 PM.
    Wile E. Coyote - "Clear as mud?"

  3. #3
    Member
    Join Date
    May 2008
    Location
    Ireland
    Posts
    77
    hey thats terrific thanks for that.

    It works too.

  4. #4
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Good, wasn't sure if it was going to work being that you specified MX04.
    Wile E. Coyote - "Clear as mud?"

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center