A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: RANDOM SOUNDS ON A MOVIE

  1. #1
    Junior Member
    Join Date
    Dec 2000
    Posts
    27
    how can i play random sound on a movie (for example, i wanna play sound like a bird......than after a random time a cricket sound.......then a dog bark......) how can i do this ?

  2. #2
    Pillow Daddy m_andrews808's Avatar
    Join Date
    May 2001
    Location
    London England
    Posts
    924
    Make a behavior MC i.e. one with no graphics only code. Make it three frames long and put this code in:

    frame1 (label "SetDelay")
    Time = Math.abs(Math.Random()*100);
    Counter = 0;

    frame2 (label "LoopStart")
    Counter = ++Counter;

    frame3
    if (Counter == Time){
    (play sound) // not sure how to play a sound from A/S if it is not possible then stick all your sounds in individual MCs and call the MC using tellTarget
    gotoAndPlay("SetDelay");
    }
    gotoAndPlay("LoopStart");


    Tis a bit confusing but the MC loops round for a random amount of time and then plays a sound and starts looping again for a different amount of time.
    Figure out what range of delays you would like this to work for and adjust te code in the first line of frame 1 to suit e.g.

    delays between 3 and 6 seconds would be this:
    Time = Math.abs((Math.random() * 36) + 36);
    For a 12 fps movie

    delays between 8 and 15 seconds would be this:
    Time = Math.abs((Math.random() * 84) + 96);
    For a 12 fps movie

    Let me know if you need help with any of this

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