Be a Supporter!
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
AS: Sound Feb. 11th, 2005 @ 09:03 AM Reply

SOUND

To get a sound into Flash: FILE>IMPORT TO LIBRARY>BROWSE>OK

BASIC USE:
Select a layer. Drag the sound from the Library to the Stage.
or
Select a layer. In the right-hand end of the PROPERTIES panel, use the dropdown to select a sound.

EVENT
If you want to loop your sound, you're generally best of choosing EVENT>REPEAT>500 in the other boxes on the PROPERTIES panel. Only one frame of the waveform has to be visible on the timeline for the whole sound to be played. NOTE: if you're planning on making loops, import .wav in preference to .mp3. Clean loops using .mp3 are virtually impossible.

STREAM
If you need the sound to be in sync (eg voiceovers), then choose STREAM. Streaming usually also knocks the .swf size down by a bit, too. If you're using STREAM, then make sure you create enough frame that the whole sound file wave shows on the timeline; any part of the waveform that's not visible won't be played.

EXPORTING:
Biggest problem with new Flash users is unecessarily large filesize due to uncompressed audio. Click FILE>PUBLISH SETTINGS>FLASH tab, and set Audio Stream and Audio Event to 64 kbps or lower (generally 32 kbps is good enough, if not 16). Press CTRL+ENTER to check the quality, and then check the size of the resulting swf - try to reach a good compromise.

ACTIONSCRIPTING:
If you're using a lot of sounds in your movie, you may want a way to manage them. There are two ways to do this (probably more).

No 1 - attachSound
Right-click your sound in the Library and select Linkage.
Tick the 'Export For Actionscript' box - the Export in First Frame box should tick itself
In the 'Identifier' box, type 'sound1'

Select the first frame of your movie, and add these actions:
bgSound = new Sound(this);
bgSound.attachSound("sound1");

When you want the sound to play, use these Actions:
bgSound.start(0, 99);

That's it. The problem now is that it loops itself, so if you want it to stop, you'll have to use stopAllSounds(); or bgSound.stop();

For more information, have a look at these:
Flash>HELP>ACTIONSCRIPT DICTIONARY>SOUND
http://www.flashbax.com/attachsound.htm
http://www.hed.swin.edu.au/design/tutorials/flash/attachsound/index.php

No 2 - Sound MC
(this is the method I generally use, it suits me but may not suit others)
Create a new MC. Give it two keyframes.
On the first frame, add a stop(); action
With the second frame selected, use the Sound dropdown at the right-hand end of the PROPERTIES bar to select a sound.
If you want it to loop:
Set it to EVENT, and select the number of times you wish it to loop. On the second frame, add gotoAndStop(1);
If you want it to stream:
Set it to STREAM, and stretch the MC out to however many frames the waveform takes. After the last waveform frame, add a keyframe (F6), and add gotoAndStop(1);

On the main stage, drag a copy of the MC from the library and give it the instance name 'Sound01'
When you want to play a sound, use:
_root.Sound01.gotoAndPlay(2);

I know I've missed a lot of stuff about sound out in this, but hopefully it will give you a basic idea to be starting from

Links:
http://www.utexas.edu/learn/flash/sound.html
http://www.macromedia.com/support/flash/how/expert/sound/sound05.html
http://www.macromedia.com/support/flash/how/expert/sound/sound07.html


- - Flash - Music - Images - -

BBS Signature
Afro-Ninja
Afro-Ninja
  • Member since: Mar. 2, 2002
  • Online!
Forum Stats
Moderator
Level 44
Game Developer
Response to AS: Sound Feb. 11th, 2005 @ 09:17 AM Reply

Also, something quick to add- when streamed sounds go out of sync, another way to fix it is to insert another layer and stream .5 seconds of silence (looped) for the length of the movie. As long as something is always streaming, all sounds should line up fine


BBS Signature
carmelhadinosaur
carmelhadinosaur
  • Member since: Jun. 23, 2003
  • Offline.
Forum Stats
Member
Level 49
Blank Slate
Response to AS: Sound Feb. 11th, 2005 @ 09:21 AM Reply

Thats very good you're doing this Denvish, and im sure alot will use it, even if they wont write... :P
Also, i think this site is great, and i've never seen anyone else but me putting a link to it ;D
http://www.stonewashed.net/sfx.html


BBS Signature
rem11
rem11
  • Member since: Nov. 12, 2004
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Sound Jun. 7th, 2005 @ 04:54 PM Reply

how do you add your own sound

Nemo
Nemo
  • Member since: Jun. 13, 2003
  • Offline.
Forum Stats
Member
Level 34
Game Developer
Response to AS: Sound Jun. 7th, 2005 @ 04:55 PM Reply

At 6/7/05 04:54 PM, rem11 wrote: how do you add your own sound

Uhh, File > Import. If you want your OWN sound, you have to record it using Soundforge or Audacity, then Export as an MP3 or WAV.


BBS Signature
rem11
rem11
  • Member since: Nov. 12, 2004
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Sound Jun. 7th, 2005 @ 06:20 PM Reply

thanx alot mate

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Sound Jun. 10th, 2005 @ 11:31 AM Reply

Really nice tutorials,one of the best in the AS section

P.S:Will you add my big physics tutorial to the AS section?Don''t you add it just because I am level 8 or what >:(
^_^


BBS Signature
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Sound Jun. 10th, 2005 @ 12:48 PM Reply

At 6/10/05 11:31 AM, Dark_Toaster wrote: P.S:Will you add my big physics tutorial to the AS section?Don''t you add it just because I am level 8 or what >:(
^_^

I added it a couple of days ago

AS: Main


- - Flash - Music - Images - -

BBS Signature
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Sound Jun. 10th, 2005 @ 12:58 PM Reply

Oh,I didn't notice it.Thanks!


BBS Signature
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Sound Jun. 28th, 2005 @ 07:07 AM Reply

Quick link job. I don't generally use attachSound when I make Flash (I generally use Sound MCs), and this seems to work on all sounds that are playing in that situation.

Fading sounds in/out


- - Flash - Music - Images - -

BBS Signature
Hopps
Hopps
  • Member since: May. 13, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to AS: Sound Jun. 28th, 2005 @ 08:50 AM Reply

Not bad example there.

- Hopps

Glaiel-Gamer
Glaiel-Gamer
  • Member since: Dec. 28, 2004
  • Offline.
Forum Stats
Member
Level 28
Game Developer
Response to AS: Sound Jun. 28th, 2005 @ 08:57 AM Reply

Man denvish it seems like you spend all your time helping people. Do you even have any time for flash?

TrueDarkness
TrueDarkness
  • Member since: Aug. 31, 2004
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to AS: Sound Jun. 28th, 2005 @ 10:08 AM Reply

No 1 - attachSound
Right-click your sound in the Library and select Linkage.
Tick the 'Export For Actionscript' box - the Export in First Frame box should tick itself
In the 'Identifier' box, type 'sound1'

Select the first frame of your movie, and add these actions:
bgSound = new Sound(this);
bgSound.attachSound("sound1");

When you want the sound to play, use these Actions:
bgSound.start(0, 99);

That's it. The problem now is that it loops itself, so if you want it to stop, you'll have to use stopAllSounds(); or bgSound.stop();

Could these codes, if set properly, be used to make pause, play, and slow motion buttons that you often see in flashes these days. Maybe if you attack a movie clip and give it the actionscript settings and just recode those codes to make it work for a movie clip.

Could that work?

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Sound Jun. 28th, 2005 @ 10:59 AM Reply

At 6/28/05 08:57 AM, Glaiel_Gamer wrote: Man denvish it seems like you spend all your time helping people. Do you even have any time for flash?

I'm not actively making anything currently - I got halfway through a game for the GoG minigame challenge and then decided it was crap - so I'm doing these while I'm waiting for some fresh inspiration.

At 6/28/05 10:08 AM, True_Darkness wrote: Could these codes, if set properly, be used to make pause, play, and slow motion buttons that you often see in flashes these days. Maybe if you attack a movie clip and give it the actionscript settings and just recode those codes to make it work for a movie clip.

Could that work?

Well, not really, this code will only apply to sound. If you're looking for movie controls, feel free to dissect this - although it doesn't have a slo-mo button


- - Flash - Music - Images - -

BBS Signature
TrueDarkness
TrueDarkness
  • Member since: Aug. 31, 2004
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to AS: Sound Jun. 28th, 2005 @ 11:11 AM Reply

Well, not really, this code will only apply to sound. If you're looking for movie controls, feel free to dissect this - although it doesn't have a slo-mo button

whoa! thanks a lot, thats exactly what I'm looking for. Adn, I didn't actually mean slow motion, I sorta meant like, a frame by frame button, each time you click it it goes up one frame, or back one frame, depending on the button. Anyway thanks a lot, im gonna be using this in a lot more flash movies now!

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Sound Jun. 30th, 2005 @ 10:46 AM Reply

Thanks AGH for this link

Fixing problems with importing sound (Flash does not support this filetype)


- - Flash - Music - Images - -

BBS Signature
Streetproject
Streetproject
  • Member since: Sep. 8, 2003
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to AS: Sound Aug. 9th, 2005 @ 11:09 PM Reply

bgSound = new Sound(this);
bgSound.attachSound("pan");
bgSound.start(0, 99);

i have multiple parts with this code, changing "pan" of course, but, i also have to change "bgSound" also right?

AGH
AGH
  • Member since: Jun. 7, 2004
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to AS: Sound Aug. 10th, 2005 @ 08:05 AM Reply

At 6/30/05 10:46 AM, Denvish wrote: Thanks AGH for this link

Fixing problems with importing sound (Flash does not support this filetype)

PhoenixJ was the one I got the link from so any credit should be sent his way, especially considering that it's his site.

azzazin
azzazin
  • Member since: Jul. 24, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Sound Aug. 15th, 2005 @ 07:09 AM Reply

im in scene 2 and frame 1 theres a on button for music i tipe in it this
on (press){
gotoandplay(scene 2, 1)
}
doesnt work :/
on (press){
gotoandplay('scene 2', 1)
}
doesnt work , and all similiar thigs dont work what to do?

Kipling
Kipling
  • Member since: May. 4, 2004
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to AS: Sound Aug. 15th, 2005 @ 09:33 AM Reply

At 8/15/05 07:09 AM, azzazin wrote: im in scene 2 and frame 1 theres a on button for music i tipe in it this
on (press){
gotoandplay(scene 2, 1)
}
doesnt work :/
on (press){
gotoandplay('scene 2', 1)
}

That has nothing to do with sound at all.

azzazin
azzazin
  • Member since: Jul. 24, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Sound Aug. 18th, 2005 @ 06:13 AM Reply

can someone give me actionscript how to make "on" button for music , i know off but i cant make that on button , soo help?

SuicideMessiah
SuicideMessiah
  • Member since: Jul. 17, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to AS: Sound Sep. 6th, 2005 @ 08:21 PM Reply

the actionscrip to plau the sound doesnt work, says " must appear within on handler"

Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to AS: Sound Sep. 6th, 2005 @ 08:49 PM Reply

At 9/6/05 08:21 PM, SuicideMessiah wrote: the actionscrip to plau the sound doesnt work, says " must appear within on handler"

* sigh
Thats because you are silly and you forgot to learn some VERY basic AS before jumping into this
try again this time read some of the help files that come with flash


- Matt, Rustyarcade.com

SuicideMessiah
SuicideMessiah
  • Member since: Jul. 17, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to AS: Sound Sep. 6th, 2005 @ 08:51 PM Reply

yup nvm im a dumbass got it now

TelaFerrum
TelaFerrum
  • Member since: Feb. 21, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to AS: Sound Sep. 6th, 2005 @ 09:14 PM Reply

At the moment I'm using streaming sound in a music video I'm doing, and because of this I can't make use of multiple scenes. An idea I considered using was putting streaming sound inside a movie clip and then using goto() each scene to match the movie clip sound with the main timeline. I was wondering whether the sound would still synch with the main timeline if it's inside a movie clip, and whether using ActionScript this way to make it synch through scenes would make the sound skip or become unsynchronized at all. Even if it's unlikely, I'd like to know if this could happen. I'll be glad if I can start using scenes.

piefi
piefi
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Sound Oct. 1st, 2005 @ 03:41 PM Reply

i have a voice over that is really quiet. how do i increase the volume in flash either manually or via AS?

Starogre
Starogre
  • Member since: May. 8, 2004
  • Offline.
Forum Stats
Member
Level 18
Artist
Response to AS: Sound Oct. 1st, 2005 @ 04:14 PM Reply

At 2/11/05 09:17 AM, Afro_Ninja wrote: Also, something quick to add- when streamed sounds go out of sync, another way to fix it is to insert another layer and stream .5 seconds of silence (looped) for the length of the movie. As long as something is always streaming, all sounds should line up fine

You could also put the streamed music/sound in a MC and extend the MC thru the whole time the sound is playing. This also gets syncing right.


the events are merely fictional, written, directed, and acted out by all who create them

BBS Signature
Starogre
Starogre
  • Member since: May. 8, 2004
  • Offline.
Forum Stats
Member
Level 18
Artist
Response to AS: Sound Oct. 1st, 2005 @ 04:16 PM Reply

Oh, and maybe add something about fading music in using AS or fading out music? Like if you get game over, you don't just want the music to skip STRAIGHT to sad music from happy or whatever...


the events are merely fictional, written, directed, and acted out by all who create them

BBS Signature
JD77
JD77
  • Member since: Mar. 30, 2005
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Sound Oct. 1st, 2005 @ 04:44 PM Reply

lol how manny more u gonna make for AS main lol
(plz dont stop they are really good tuts!)

WTF! lol...


*User Page under construction*

BBS Signature
Rammer
Rammer
  • Member since: Jun. 8, 2003
  • Offline.
Forum Stats
Member
Level 33
Programmer
Response to AS: Sound Oct. 1st, 2005 @ 06:04 PM Reply

you forgot loadSound (:

it loads a sound dynamically from a URL. works kinda like this

loadSound("http://rammerzworld.com/sound.m
p3", true)

the "true" in there sets it to stream the sound, i think.


snyggys