Tutorials Home
What's New
Top Rated
Submit
myTutes
Random!
Flash MX Sound Object Tutorial
Author: Kenny Bellew
How to Load an External MP3 from a Text Input Box
|
If you want to be able to type in the file name of an MP3 file into a text
box, and press a button to have that file play, the following could be used:
- Create an input text box and give it a variable name like "songInput" (as
shown below).
- Place a button on stage and put the following code on the button:
on(press) {
if (songInput!=nul && playing!=true) {
playing=true;
myInputSound = new Sound(myInputSoundMc);
myInputSound.loadSound(songInput);
myInputSound.start(myPausePosition,0)
}
}
 |
Fig. 19: Example of input-text box properties, showing variable name
location
|
- Place another button on stage for stopping the sound with the following:
on(press) {
//Stop Button
mySound.stop();
myInputSound.stop();
playing=false;
myPausePosition=0;
}
This is one case in which you have to break the rule of defining all sound
objects in the same location. When the button is pressed, the value of "songInput"
is inserted during the sound object definition.
| » Level Intermediate |
|
|
Added: : 2002-08-13
Rating: 9.11 Votes: 663
Hits: 3054
|
| » Author |
|
Kenny Bellew is a technical writer in Minneapolis, MN. He's currently interested in becoming involved in other writing-related Flash projects.
|
| » Download |
|
Download the files used in this tutorial.
|
|
Download (6170 kb)
|
|
Get conversion and unzipping tools
for PC and Mac here!
|
| » Forums |
|
More help? Search our boards for quick answers!
|
|
Please rate this tutorial, 10 is the top rating, you can also click the
comments link to read/write a review.
|
|
|