# Random Songs?

**URL:** <https://forum.kirupa.com/t/random-songs/184155>\
**Category:** flash\
**Created:** [April 2, 2006, 7:31pm UTC](https://forum.kirupa.com/t/random-songs/184155 "2006-04-02T19:31:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin105](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@Robin105](https://forum.kirupa.com/u/Robin105)\
**Post date:** [April 2, 2006, 7:31pm UTC](https://forum.kirupa.com/t/random-songs/184155/1 "2006-04-02T19:31:15Z")

</div>

Hey guys i am back for more flash help :love:

How can i make a button that u can click and it will play a random song, after it plays the first RANDOM song then it will play another song at RANDOM

Example: I got 8 songs  
song1  
song2  
song3  
song4  
song5  
song6  
song7  
song8

When clicked on PLAY button it plays like this:  
song3  
song8  
song1  
song6  
song7  
song4  
song6  
song5  
song7  
song4  
song1  
song2  
song8  
song7  
Onwards …

Plz help 😃 THANKS!

---

<div class="post-metadata">

**Author:** ![Henxon](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@Henxon](https://forum.kirupa.com/u/Henxon)\
**Post date:** [April 2, 2006, 10:09pm UTC](https://forum.kirupa.com/t/random-songs/184155/2 "2006-04-02T22:09:23Z")

</div>

ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#808080]_//Put the songs into an array called mySongs_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] mySongs:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];  
mySongs[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR] = sound1;  
mySongs[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR] = sound2;  
[COLOR=#808080]\*//…  
\*[/COLOR][FONT=Courier New] mySongs[COLOR=#000000][9[/COLOR][COLOR=#000000]][/COLOR] = sound10;[/FONT]

[COLOR=#808080]_//play random song from 1-10 (0-9 in the array)_[/COLOR]  
[COLOR=#000000]**theButton.onRelease = function(){  
var**[/COLOR] num:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR]COLOR=#000000[/COLOR]-[COLOR=#000080]1[/COLOR];  
mySongs[COLOR=#000000][[/COLOR]num[COLOR=#000000]][/COLOR].[COLOR=#0000ff]play[/COLOR]COLOR=#000000;  
}  
[/COLOR]  
[/LEFT]  
[/FONT]

/henxon
