need HELP putting seamless sound in backgrd of swf

  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

Hey Everybody..how's it goin?

Here's my problem. I'm a newbie to flash so this might be easy for you all..but i'm clueless. Anyways, I have a flash movie I made and I want to be able to put a 'seamless' sound that is always playing all the time..regardless of what people click on or do within the movie. Is there a way to do this, and if so, HOW?

the name of my mp3 file is 'air' which is just a sample of wind. Right now it's currently in my library. I have about 8 layers in my file.

any help, much appreciated :wink:

chal7ds
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Use the Sound() Object http://www.kennybellew.com/tutorial/
  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

ok..i'll try that..get back to you if i can't figure somethin out..

thanx
  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

okay..this s#%t is confusing as hell! especially since I am NEW to this thing..but I tried with all my brain power to understand and I think in my case (for what i want) i should follow Kenny's "How to load an external mp3 using the loadSound method" which i've pasted below so that i can ask some questions that are boggling my mind (my questions are below Kenny's instructions)

Instructions for loading an external mp3 using loadSound:

The "loadSound" method of the sound object allows MP3 files to be loaded dynamically. Most of what has already been described about sound objects is true for dynamically loaded sound objects. The notable exceptions involve loading the sound object as streaming versus as an event. If the sound object is loaded as streaming, it begins to play before it has completely downloaded onto the user's computer. If the sound object is loaded as an event, the file must completely load before it can be played. The advantage of loading the audio as streaming is that it plays sooner. The advantage of loading the audio as an event is that it has, potentially, better sound quality.




The syntax for dynamically loading a sound object with an instance name of "myMusic" is as follows:

myMusic.loadSound("url", isStreaming)

Commonly, the sound object method, "loadSound", is used as follows:

myMusic.loadSound("sample.mp3", true);

In the above example, the MP3 file, sample.mp3, is loaded from the same folder that contains the SWF file. It loads into the sound object "myMusic", and it is loading as a streaming sound object. Concerning loading as streaming or as an event, loading as an event is the default. If neither true or false is specified for streaming, the sound object will load as an event.

To use the loadSound method, the sound object must still be defined. The main difference being that it is not attached to a sound in the library. The following is a common way to define the sound object with the loadSound method:

myMusic = new Sound(myMusicMc);
myMusic.loadSound("sample.mp3");

In the above example, a new sound object is defined with the instance name of "myMusic", and will load as a child of the movie clip with an instance name of "myMusicMc". This will give you the ability to control its properties independent of movie clip sounds on other timelines.

In the second line, the external file "sample.mp3" is instructed to load into the sound object "myMusic". It will load as an event, versus streaming, as the Boolean value of true or false is not specified. Therefore, the default status (event) will be used.

All of the controls for sound objects described thus far work for dynamically-loaded streaming MP3s, with the exception of starting the MP3 with the mySoundObject.start() method. Streaming MP3's start as soon as there is enough data to play the sound; therefore, the loadSound call to the sound object is the start command. However, you should be able to stop the streaming sound and restart it with the mySoundObject.start().

------------------------------------------------------------------------------------------
Ok..so here's what confuses me. The sound object which gets defined..in this case, in his example he calls it "MyMusic". What the hell is that? Do I have to make something inside flash (like an MC) or something and call it a name and that's what my sound object is? Is that 'physically' what a sound object is? Like, what the hell 'exactly' IS a sound object? How do I make it and name it?

Secondly, what confuses me..is the defining part. Do I have to make an invisible MC in flash and give it a name (his was called "MyMusicMc") but then this confuses me more because i am dependent on knowing my first confusing question above about 'physically' making the sound object. If it's an mc that i made, does the new invisible mc i make get attached to that or something? and then i guess the "air" mp3 of mine loads from that sound object i created?!?

Finally, he doesn't really specify where to put all this code. Do i make a new layer and put all this code on the first frame one after another in the script pane? Or do I just add actionscript to the first frame on the bottom layer that already exists in my swf and put the code in there one after another? New layer, or no new layer? first frame?

I think what's killing me on this is that i don't really know flash jargon..so what i may be perceiving a word he uses as..might totally be something different (for example, i may be talking out my ass when it comes to this sound object thing being an mc i create)

If anyone could just PLEASE explain this in more human english terms of how this works..I WOULD REALLY APPRECIATE IT! just help me understand how to make these things he's talking about or tell me what exactly they are...if u can..

thanx!!!! 2 anyone..!!
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Actually if you have the mp3 in your library you can use attachSound()...

http://www.kennybellew.com/tutorial/how_to_define.htm
  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

okay...i tried the attachSound method this time. It didn't work. Here's what I did:

I pasted this code in the first frame of my swf (i called my identifier "air01" in the Linkage panel):

air=new Sound();
air.attachSound("air01");


I exported the file hoping to hear the sound.....but......nothing.

He says something in that tutorial about 'calling into action' after you've defined it, however, he never explains how to do that. Am i supposed to put some script somewhere else telling it to play somehow or something?

If that's not the problem, there's a couple of other factors which i'm thinking about that might be reasons why it's not playing. For instance, the first 4 frames of my swf consist of the 'preloader' before the actual swf starts going into action with animation. Could it be that it's not playing because it can't load that script i put in the first frame due to the preloader script above it? And if this is so, that means i would have to put the script on the 5th frame (where the REAL animation starts), but, the problem with doing that..is that in the linkage identifier box..it only has an option that says "export to first frame"...it doesn't give you any other option to work with here?!?!

the other reason it might not be playing is because the first five frames (which carry the preloader) are at the topmost layer. Is that the root layer? i think it's supposed to be on the root layer, no?

It might be a case where both of these problems are co-producing a problem.

do you know what my problem is? What am i doing wrong?
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

I think one of your problems is that your missing a parameter when you add the sound. Flash doesn't know how to get the file.

try this instead.
air=new Sound();
air.attachSound("air01",true);


if it still doesn't start playing you could try adding a button that uses

Code: [ Select ]
buttonInstanceName.onRelease = function(){
air.play();
}
  1. buttonInstanceName.onRelease = function(){
  2. air.play();
  3. }


hope that helps.
  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

Well, i tried putting the 'true' value in there..but still no luck. i also don't want to try that button method..becuz that's not how i want the movie to be. the user is supposed to just come to the movie and the background sound already automatically starts playing..

? ?

anyone else have any help, suggestions on this matter?
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Do you require any control over this sound, such as a mute button or anything?

If not... click on the first frame of your movie (or create a frame where you want the sound to start), and just drag the sound from the library onto the stage. It will place it on your timeline.

I recommended the Sound() object before because it allows you to have control over the sound you play, but as it stands right now I really don't have the time to debug your code and figure out what is going on. I am sorry.
  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

the thing is...my movie has a bunch of different scenes..and within scenes..some of the frame lines start and stop in places..cause i've actually tried the dragging method..and it works..but then when i preview my movie..it doesn't do it when i click on other functions within the movie which lead to other scenes. that's why i wanna do the attachSound thing becuz then it will run in the background independent of all the functions within the movie.

you don't have to debug my code right now (or ever lol) ..but if you get time some other time..that'd be cool..

ok..laters
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

In response to your last post. The root level isn't a layer... timelines in Flash are like a hierarchy menu... such as that in an operating system for files.

The _root timeline is the timeline you start off with in Flash. Now say you create a movieclip symbol, you can double click that symbol and there you have a secondary timeline... this would be like a directory in an OS.

Now back to your Sound() issue.


It doesn't look like you've called a Sound.start() function. So try this
Code: [ Select ]
air=new Sound();
air.attachSound("air01");
air.start(0, 99);
  1. air=new Sound();
  2. air.attachSound("air01");
  3. air.start(0, 99);


0 is the seconds offset value... so if you want it to start later in the sound you change this to a higher number, 0 is from the beginning. 99 is the loop amount. Right now it will loop this sound 99 times. Why Macromedia didn't just allow you to loop it infinitely I don't know (or maybe they did in MX 2004?), but if someone listens to a loop more than 99 times they probably are asleep anyway.
  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

IT WORKED!!!

YOU RULE!

i can't believe it finally worked. THANKS a million!
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

No problem... but if you want to make things more complicated.

In order to attach sounds, if you noticed in your linkage settings the checkbox 'export to first frame' gets checked automatically. This is required so that the file is loaded entirely before getting played. This is all well and good, but first frame is actually an invisible frame 0 that you have no access to, which is before your preloader. So on the web it will load your music, then show your preloader and preload the rest of the site.

ACK!

Solution:

This is what I always do. Create an empty frame right after your preloader frame(s) (start your movie after this empty frame). What you will want to do is like I mentioned in my last post. Take your sound and drag it to this empty frame. Then, go back into the linkage settings and uncheck the 'export to first frame' checkbox. Now go back to your preloader code, and I'm sure in the if (bytesloaded == bytestotal) or whatever statement you have you have a gotoAndPlay() initiate. Change this value to skip over the frame with the music (so the music doesn't play) and go right to the beginning of your animation.

Why does this work? Well because Flash exports to frame 0 to make sure that it gets loaded before it gets called... otherwise the call will fail. If you add the object on a frame so that the preloader can load it there is no need for this. So you can uncheck that box and prevent that lag before the preloader.
  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

It's not working for some reason..i did all the steps just like you said...but i don't hear any sound..

Do i have to put the code on the same empty frame i created? or does it stay on the first frame? (that's how it is right now)
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You should put the code on the frame after the empty frame created. Since your preloader will jump over the empty frame (given you adjusted it's actions correctly) and start right on your animation.

I don't know how your frames are setup so I can't give you specific frame numbers.

I usually have

Frame 1 = Preloader
Frame 2 = Empty frame for attachable clips
Frame 3 = Start of movie

And in my preloader code when the movie is fully loaded I have it gotoAndPlay(3);
  • chal7ds
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: PA

Post 3+ Months Ago

hmmmm..it's still not doing it. i'm not sure why..but it actually no big deal because the sound is actually 'wind'..so i don't really mind that it starts playing while the preloader is going. in other case, i totally would mind..but for this app, it works okay..

Post Information

  • Total Posts in this topic: 16 posts
  • Users browsing this forum: No registered users and 20 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.