Example: Playing a sound file

In this example, we will create an application consisting of several files (an SWF file and a sound MP3 file). The player uses the value of the mp3file variable as the path to the file that should be played. To show the player the path to the MP3 file, we will use the SWF variables option of the compiler. This option allows you to declare variables in the startup SWF file right before its initialization.

Note.
We could specify the variable explicitly right in the SWF file, but we will use the SWF variables option in order to get acquainted with the features of the compiler.

Do the following to create an application playing a sound file:

  1. Open Chameleon Flash. Note: As Chameleon Flash Lite edition cannot compile projects consisting of many files, you should use Standard or Pro edition to be able to compile this application.
  2. Click File > New From... and select one of the EXE application project files created in the previous examples.
  3. Open the Project editor.
  4. Open the Source tab.
  5. Select the “Compile Directory with files” option and specify the path to the “soundplayer” directory located in the “Tutorials” directory. This directory contains two files: soundplayer.swf and sound.mp3.
  6. Use the Startup file field to specify the path to “soundplayer.swf”.
  7. Since “soundplayer.swf” reads the value of the “mp3file” variable, we will specify it in the SWF Variables field. Enter “mp3file=sound.mp3” (without the quotation marks) in this field.
  8. Click Ok.
  9. Click Save to save the project.
  10. Compile the application.
  11. Run the application. As you can see, an application created with Chameleon Flash may include a lot of files connected with each other.