Solved

Play an MP3 or aiff file in Flash 8?

Posted on 2007-03-29
39
889 Views
Last Modified: 2013-11-13
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?
0
Comment
Question by:icpearson
  • 21
  • 18
39 Comments
 
LVL 11

Expert Comment

by:sibgig
ID: 18816196
0
 
LVL 11

Expert Comment

by:sibgig
ID: 18816199
while the title says Flash 2004, it will work fine in Flash 8 too.
0
 

Author Comment

by:icpearson
ID: 18829069
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18829273
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
 

Author Comment

by:icpearson
ID: 18836533
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18836829
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
 

Author Comment

by:icpearson
ID: 18837027
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18837263
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
 

Author Comment

by:icpearson
ID: 18837301
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18837461
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
 

Author Comment

by:icpearson
ID: 18837586
I just uploaded a zipped file entitled "myfile" to the site.
0
 
LVL 11

Expert Comment

by:sibgig
ID: 18837943
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
 

Author Comment

by:icpearson
ID: 18838006
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18838096
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
 

Author Comment

by:icpearson
ID: 18843906
Were you able to retrieve the file and take a look at the code?
0
 
LVL 11

Expert Comment

by:sibgig
ID: 18844792
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
 

Author Comment

by:icpearson
ID: 18846736
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18846901
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
 

Author Comment

by:icpearson
ID: 18846932
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 11

Expert Comment

by:sibgig
ID: 18847188
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
 

Author Comment

by:icpearson
ID: 18850420
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18851999
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
 

Author Comment

by:icpearson
ID: 18852201
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18852514
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
 

Author Comment

by:icpearson
ID: 18853812
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18853952
exactly.

so now you'll need to tweak your buy.fla timeline a little.
0
 

Author Comment

by:icpearson
ID: 18858767
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18858911
ok
your last file was at:
http://www.betsyhickok.com/myfile/myfile.zip

where is this one?
0
 

Author Comment

by:icpearson
ID: 18859480
0
 
LVL 11

Expert Comment

by:sibgig
ID: 18860274
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
 

Author Comment

by:icpearson
ID: 18860368
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18860550
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
 

Author Comment

by:icpearson
ID: 18860744
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18862146
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18863394
oh and this actionscript goes on the play button

on(release){
      _root.mySoundBeat.start("", 1);
      gotoAndStop("stop");
}
0
 

Author Comment

by:icpearson
ID: 18869570
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
 
LVL 11

Expert Comment

by:sibgig
ID: 18974929
did you get your file working properly?
0
 

Author Comment

by:icpearson
ID: 18989765
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
 
LVL 11

Accepted Solution

by:
sibgig earned 500 total points
ID: 18989927
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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now