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:
- 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.
- Click File > New From... and select one of the EXE application project
files created in the previous examples.
- Open the Project editor.
- Open the Source tab.
- 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.
- Use the Startup file field to specify the path
to “soundplayer.swf”.
- 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.
- Click Ok.
- Click Save to save the project.
- Compile the application.
- Run the application. As you can see, an application created with
Chameleon Flash may include a lot of files connected with each other.