Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
In this add-on, you will program music that will play when the flag is clicked.
Many profile pages are customized with music!
It allows people to share their favorite songs or music that they like.
To start, click the music sprite, then click the looks menu and the show block.
Click the costumes tab to see the three costumes in the music sprite.
This example will use the drum costume, but you can use any costume you'd like.
You can move the music sprite to a different spot on the stage.
Next, click on the sounds tab on your project, then on "choose new sound from library."
You will find many different sounds there that you can use in your program.
There are different categories of sounds.
Click on the "Music Loops" category on the left to see different music loops, or short
sections of music tracks.
These loops are longer than other sounds.
Press the "play" button on each sound to hear it.
When you find a song you like, click on it, then click "OK."
You can now add the new song to your project.
To do that, click on the scripts tab, click on the sound menu, and drag a "play sound
until done" block into the script editor.
The "play sound" block plays a specific sound without pausing the rest of the code.
This block is mostly used for quick sound effects.
The "play sound until done" block, on the other hand, pauses the rest of the code until
the sound has finished playing.
For this example, using a "play sound until done" block will prevent your music from being
To make this code start when a user clicks the flag, add a "when flag clicked" event
to the top of this code stack.
Click the flag to test your code.
The music plays!
Now, it’s your turn.
Show the music sprite and select a costume.
Add a "play sound until done" block under a "when flag clicked" event, so the music
will play when the flag is clicked.
As an added challenge, make your music play forever using a "forever loop" from the control
menu, and code your music to play when the sprite is clicked instead of when the flag