Play an MP3 or aiff file in Flash 8?

How do you create a way for a user on a Flash web site, to click on a link and play an MP3 or aiff file in Flash 8?
icpearsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom RayCommented:
0
Tom RayCommented:
while the title says Flash 2004, it will work fine in Flash 8 too.
0
icpearsonAuthor Commented:
Thanks....this does work.  The only problem I'm having is that the swf works just fine on my local computer, but when I upload this swf to my remote host, the file will not play the music file. Is there something else besides the swf I need to upload to my remote host?  How can I make this work?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Tom RayCommented:
have you embedded the sound in flash, or are you linking to it?

if you've embedded it all you would need is the swf. otherwise for linking, the aiff or mp3 would need to be uploaded as well.
0
icpearsonAuthor Commented:
How do you embed your sound file in Flash 8?  

Also, I am encountering a problem creating more than 1 music file to listen to using this tutorial you gave me:
http://www.smartwebby.com/Flash/sound_button.asp

I works great for 1 file, but when I try to do more than one....and I do change the name of the sound file in the code....it just plays the same sound file over again, as if it links back to the same sound file even though I change the name of it in the code....any thoughts on this?
0
Tom RayCommented:
on that web page under the section labeled "Preparing your buttons, importing your sound file and setting your timeline" is how to embedded a sound.

if you want more than one sound you'll need a button for each sound (using this tutorial).

can you upload your file? i'd be happy to look at it.
0
icpearsonAuthor Commented:
Yes, there are 3 swf files uploaded....home, about Betsy, and buyCD....take a look....I just uploaded the mp3 file to the remote site, but I still can't get it to play. I will also take a second look at the website under "Preparing your buttons, importing your sound file and setting your timeline"

The url for this site is:

www.betsyhickok.com

Thanks!
0
Tom RayCommented:
no... i was referring to uploading your fla file so that i could download and take a look at your file and code to help you out.

i like the transitions though.
0
icpearsonAuthor Commented:
I did follow the instructions for preparing the buttons, ect....and embedded the mp3 according to the tutorial and it uploaded everything to my remote host and still nothing works....tell me how to upload the fla file so you can see it.
0
Tom RayCommented:
well you seem to have access to www.betsyhickok.com

just put the fla and mp3 into a folder named 'myfile' (or anything you want to name it)

zip or stuff it, creating a zip file named 'myfile.zip'

then put the zip file into another folder named 'ee' (or anything you want to name it).

upload that folder to the site.

then i could download by going to:
www.betsyhickok.com/ee/myfile.zip

0
icpearsonAuthor Commented:
I just uploaded a zipped file entitled "myfile" to the site.
0
Tom RayCommented:
sorry not getting it.

try this, i knew ee had a place for this kind of thing but couldn't find it earlier.

go to:
http://www.ee-stuff.com
and login with your ee login and password.
choose 'expert area' tab'
click 'upload a new file'
follow instructions and let me know what the link is.
0
icpearsonAuthor Commented:
I'm logged in, but I'm wondering what they want for:

Simply type the complete URL of the question, or the Question ID into the text box labeled "Question", and then click "Browse..." to select the desired file to upload.

What is the URL of the question  or  the Question ID?  Where can I find this?
0
Tom RayCommented:
here is the url:

http://www.experts-exchange.com/Programming/Multimedia_Programming/Audio_Editing/Q_22480169.html


its just the page that this question is on.

questions id is probably 22480169.
0
icpearsonAuthor Commented:
Were you able to retrieve the file and take a look at the code?
0
Tom RayCommented:
if you went to www.ee-stuff.com to upload i think it should have told you want the link is. you'll need to let me know that link.

i went to www.ee-stuff.com and pluged in question url:
http://www.experts-exchange.com/Programming/Multimedia_Programming/Audio_Editing/Q_22480169.html

and question id:
22480169

but it said no file was found.
0
icpearsonAuthor Commented:
Wow, I cannot get the www.ee-stuff.com to load my zip file. Everytime I try I get a message:       
"Invalid Question value
File is too small, probably not an error you've gotten before. Usually happens with empty txt files"

I don't know what to do here....can you give me some advice?  Should I contact your support?
0
Tom RayCommented:
not sure what to tell you.

back to www.betsyhickok.com site.

if you log into that site (via ftp i suspect), where in the hierarchy did you put "myFile.zip" ?
was it on the root level?
since the time when you've uploaded it, can you download it via a web browser?
if so, what is that address?
0
icpearsonAuthor Commented:
I just uploaded the myfile.zip to the remote server.  It is in a folder called "myfile".  I am uploading using Dreamweaver 8....does this help any. It is on the root level.
0
Tom RayCommented:
thats the info i needed! didn't know you had in a folder name myfile.

i got it now.

the reason www.ee-stuff.com didn't work for you is b/c they have a 4mb file limit. the file i downloaded is 31mb.

i see your problem (i think)
verify
currently you have just one song listed, i think you want to add to that list and have the same kind of "play" button next to each song. correct? something like this:
http://www.tsquared.com/ee/icpearson/

let me know if this is correct, if not explain again.
0
icpearsonAuthor Commented:
Yes, this is correct.  Glad you were able to retrieve this file.  So, as you can see, I can't get the music to play on-line, even when I embed the mp3 file. I've uploaded mp3 also....still doesn't work. Also, the swf takes forever to load on dsl....is there any way to decrease the loading time on this swf?  Maybe I will have to have a pre-loader for these pages?  And the other problem is that when I have more than 1 button for the mp3 file, even though I create a new button with a different name, it will still act as 1 button, playing the same song....Thanks for looking at this file!
0
Tom RayCommented:
alright we're on the same page.

you followed the tutorial correctly. however, in your situation you want
to create a movie clip for each sound. then place each of those movie
clips on the main timeline.

you have the button for the sound ON the main timeline.

i pulled this together as an example for you to see:
http://www.tsquared.com/ee/icpearson/songs.html

now for the size of the file
two reasons for the large file size
a. you are using a great deal of bitmap images, flash is better suited with
vector art. this is a factor but not the biggest factor
b. your song file. using the sound object method like we are, the sound
is being exported in the first frame. this is why it takes so long to
load. this is the main factor.

here is the real problem... the more songs you add the longer its going to
take to load.

there are a few ways around this depending on design and how you want
the client's visit to be.

1. you could create each movie clip in its own separate flash file. then import
those swf's into your main fla when needed (when someone clicks on the
button).
example:
http://www.tsquared.com/ee/icpearson/load.html

or

2. you create each movie clip in its own separate flash file (same as above). then when the user clicks to play a song, pop open a new browser window with just that
song swf for them to play.
example:
http://www.tsquared.com/ee/icpearson/popopen.html
this method requires that users don't have any kind of 'block pop-up windows' software activated.

with either of these, i would build a pre-loader on each of separate flash files, that way when you 'load' or 'open in a new window' the pre-loader will play while loading the swf. fyi there is no pre-loader in the examples i've shown.
0
icpearsonAuthor Commented:
So the way it is setup on my timeline is the music, which I have labeled "Mix1" is embedded and the code:

 my_sound = new Sound();
my_sound.attachSound("mix1");
play();

is retrieving the Mix1 and playing it....this according to the tutorial.  So, making the sound file it's own seperate movie clip....would I use this same code, only the mix1 would be a movie clip?  I'm still a little confused....what code would I use?  Would the movie clip (mix1) be on the main timeline?  Can you show me the code you used for creating this:

http://www.tsquared.com/ee/icpearson/songs.html

As you can see I am learning along the way here, so thanks for your patience and help.


0
Tom RayCommented:
no problem, take a look at that link again. at the bottom is a link to download the file and see it for yourself.
0
icpearsonAuthor Commented:
I noticed that the song.fla is set up differently than that tutorial I initially looked at.  Would I set up the buy.fla the same way as you have set up the song.fla?  In other words should I use these 3 layers and the code for song.fla on my buy.fla timeline instead of what I am trying to use now?  
0
Tom RayCommented:
exactly.

so now you'll need to tweak your buy.fla timeline a little.
0
icpearsonAuthor Commented:
I uploaded another folder called myfile to ee....the fla file is called buycd.fla. I still cannot get the music to play on the web....I seemed to follow all the coding that you gave me....can you look at this file and try and see why this won't play?  Maybe it is the sound file?  
0
Tom RayCommented:
ok
your last file was at:
http://www.betsyhickok.com/myfile/myfile.zip

where is this one?
0
icpearsonAuthor Commented:
0
Tom RayCommented:
i just published your file and put it on my site:
http://www.tsquared.com/ee/icpearson/buy/

works fine. sound comes on when i click the button and turns off when i click again.

the only thing is the swf is over 3mb big. thats HUGE in flash terms. depending on your connection to the internet, it may take awhile to fully load.

does the above link work for you?
0
icpearsonAuthor Commented:
Yep, it works fine on your site.  Did you alter any of the code or did you just publish it?  I have opened this site....www.betsyhickok.com  on both Firefox and Safari and I can't hear the music file....any suggestions?  Also, what would help get this file size down?

Thanks
0
Tom RayCommented:
it looks like you have a flash file for www.betsyhickok.com

and clicking 'buy' imports the swf file we've been looking at. correct?

are you using loadMovieNum or loadMovie or something else to import the buy_cd.swf?

to get your file size down, trash everything NOT being used in the library. if thats applicable, see what kind of savings that gets you.
0
icpearsonAuthor Commented:
I have a home page and the action code I use for  importing the swfs is:

buy_btn.onRelease = function  () {
      myLoader.contentPath = "buy_cd.swf";
}
0
Tom RayCommented:
ok... then we need to use the attachSound method a little differently since the file that has the sound is being imported.

currently, we have the attachSound method set up like this:
mySoundBeat = new Sound();
mySoundBeat.attachSound("beat");

change that to this:
_root.mySoundBeat = new Sound(this);
_root.mySoundBeat.attachSound("beat");

that will do it.
0
Tom RayCommented:
oh and this actionscript goes on the play button

on(release){
      _root.mySoundBeat.start("", 1);
      gotoAndStop("stop");
}
0
icpearsonAuthor Commented:
Everything works now....thanks!  Now I need to put my buttons where your I have inserted your buttons....I'll let you know how that goes.
0
Tom RayCommented:
did you get your file working properly?
0
icpearsonAuthor Commented:
Hey sibgig....I'm back again for more of your expert advise.  I did finish the web site you were helping me with.   www.betsyhickok.com

I am working on a new flash website and was wondering if you can help me create a dropdown menu similar to this:
http://lonnatucker.com/Artist.asp?ArtistID=1366&Akey=639NL2EA

Any help would be appreciated.

thanks
0
Tom RayCommented:
sure i can, i'd be happy to help, however, ee policy says you need to accept a solution for this question, award points/grade, and then start a new thread for the new question.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Multimedia Programming

From novice to tech pro — start learning today.