# Help Needed In Flash! Very Important! Need Quick!



## BlingBling 3k12 (Mar 17, 2002)

i am using the Flash MX trial and i need help... i need to know (in detail) how to insert an audio file *and* make a pause and play button control the audio (in case someone would get annoyed)

any help would be appreciated! even if you have flash 4 or 5 it would probably work... please help!!!!!!

anyone with flash experience wanted!


----------



## vic (Mar 17, 2002)

Creating sound controls 

You use the built-in Sound object to control sounds in a movie. To use the methods of the Sound object, you must first create a new Sound object. Then you can use the attachSound method to insert a sound from the library into a movie while the movie is running. 

To see an animated demonstration of sound controls, click the Play button and adjust the volume and pan. 



The Sound object's setVolume method controls the volume, and the setPan method adjusts the left and right balance of a sound. 



The following procedures show how to create sound controls like the ones shown above. 

 
To attach a sound to a Timeline: 
1	
	Choose File > Import to import a sound.

2	
	Select the sound in the library, right-click, and choose Options > Linkage.

3	
	Select Export for ActionScript and Export in first frame; then give it the identifier a_thousand_ways.

4	
	Add a button to the Stage and name it playButton. 

5	
	Add a button to the Stage and name it stopButton. 

6	
	Add a movie clip to the Stage and name it speaker.

7	
	Select frame 1 in the main Timeline and choose Window > Actions.

8	
	To pause the movie until the user selects Play, in the Actions toolbox, click the Objects category, click Movie, Sound, and Methods, and double-click stop. Enter _root.speaker in the Object text box.

9	
	To create a new Sound object, in the Actions toolbox, click the Objects category, click Movie, click Sound, and double-click new Sound. Enter song = in the Expression text box.

10	
	In the Actions toolbox, click the Objects category, click Movie, Sound, and Methods, and double-click attachSound. Enter song in the Object text box and "a_thousand_ways" (including the quotation marks) in the Parameters text box.

11	
	To start the song, in the Actions toolbox, click the Objects category, then click Movie, Sound, and Methods, and double-click start.

12	
	To activate the speaker, in the Actions toolbox, click the Objects category, then click Movie, Movie Clip, and Methods, and double-click play. Enter _root.speaker in the Object text box.

Your code should look like this:


_root.speaker.stop();
song = new Sound();
song.attachSound("a_thousand_ways");
_root.playButton.onRelease = function() {
    song.start();
    _root.speaker.play();
};

13	
	To stop the speaker when the song ends, click the Objects category, then click Movie, Sound, and Events, and double-click onSoundComplete. Enter song in the Object text box. Enter onSoundComplete in the Method text box.

14	
	In the Actions toolbox, click the Objects category, click Movie, Sound, and Methods, and double-click stop. Enter _root.speaker in the Object text box.

Your code should look like this:


_root.speaker.stop();
song = new Sound();
song.attachSound("a_thousand_ways");
_root.playButton.onRelease = function() {
    song.start();
    _root.speaker.play();
    song.onSoundComplete = function() {
        _root.speaker.stop();
    };
};

15	
	Choose Control > Test Movie to hear the sound.

 
To create a sliding volume control: 
1	
	Drag a button to the Stage.

2	
	Select the button and choose Insert > Convert to Symbol. Be careful to choose the movie clip behavior. 

This creates a movie clip with the button on its first frame.

3	
	Select the movie clip and choose Edit > Edit Symbol.

4	
	Select the button and choose Window > Actions.

5	
	Enter the following actions:


on (press) {
    startDrag("", false, left, top, right, bottom);
}
on (release) {
    stopDrag();
}

The startDrag parameters left, top, right, and bottom are variables set in a clip action.

6	
	Choose Edit > Edit Document to return to the main Timeline.

7	
	Select the movie clip on the Stage.

8	
	Enter the following actions: 


onClipEvent (load) {
    top = _y;
    bottom = _y;
    left = _x;
    right = _x+100;
    _x += 100;
}
onClipEvent (enterFrame) {
    _root.song.setVolume(_x-left);
}

9	
	Choose Control > Test Movie to use the volume slider.

 
To create a sliding balance control: 
1	
	Drag a button to the Stage.

2	
	Select the button and choose Insert > Convert to Symbol. Choose the movie clip property.

3	
	Select the movie clip and choose Edit > Edit Symbol.

4	
	Select the button and choose Window > Actions.

5	
	Enter the following actions:


on (press) {
	startDrag ("", false, left, top, right, bottom);
	dragging = true;
}
on (release, releaseOutside) {
	stopDrag ();
	dragging = false;
}

The startDrag parameters left, top, right, and bottom are variables set in a clip action.

6	
	Choose Edit > Edit Document to return to the main Timeline.

7	
	Select the movie clip on the Stage.

8	
	Enter the following actions:


onClipEvent(load){
	top=_y;
	bottom=_y;
	left=_x-50;
	right=_x+50;
	center=_x;
}

onClipEvent(enterFrame){
	if (dragging==true){
		_root.s.setPan((_x-center)*2);
	}
}

9	
	Choose Control > Test Movie to use the balance slider.


----------



## vic (Mar 17, 2002)

heres another one:

book mark this site:

http://www.flashkit.com/tutorials/Interactivity/Sound_To-Michael_-72/index.shtml


----------



## rinse (Mar 18, 2002)

why not just use movie clips?

tell target and start and stop a empty movie clip.

simple.


----------



## vic (Mar 18, 2002)

are u shure the movie clip should be empty? should it not have the sound file in it?


----------



## rinse (Mar 20, 2002)

yes, sorry, i thought that was inferred... the movie clips should have sounds files in one of the frames.


----------



## vic (Mar 20, 2002)

is this guy listening to what we said?


----------



## evildan (Mar 20, 2002)

Using a movie clip is the technique I use all the time.

It works out very well... the code is simple. Just create a movie clip for each sound, each clip holds one sound and use tellTarget command to start, and stop the desired movie clip.

Am I missing something here? This seems too simple.


----------



## vic (Mar 21, 2002)

tell target is a phased out comand


----------



## vic (Mar 21, 2002)

use  

objects>movie clips>metods>(start/stop)

ex: myMovie.stop();

i believe, tell me if i am wrong...


----------



## evildan (Mar 22, 2002)

whatever... 

Do you mean no one uses TellTarget anymore? Or it's not in Flash MX?


----------



## mrfluffy (Mar 22, 2002)

try www.actionscript.org which isnt as content-heavy as flashkit, but has a better forum


----------



## vic (Mar 22, 2002)

it is stil there, but if you look in flash mx actions sections, it has a "deprecated" section, and all comands there are discouraged from being used in new content, it would still work, but now for many new releases of flash, sooner or later they will not include support for that actionscript, so you gotta do it in the new way the suggest.

and if i help you i dont expect a whatever.


----------



## BlingBling 3k12 (Mar 24, 2002)

thanks guys! it helped alot!


----------



## rinse (Mar 25, 2002)

yeah.... i saw it is deprecated...

after poking around in Flash MX i have determenied a couple of things...

1. I need to brush up on my ActionScripting. (I have been a Flash User since Version 3)

2. There is virtually no reason for Director / Shockwave anymore. (Except maybe 3D and a few other applications)


----------



## Lazzo (Apr 12, 2002)

rinse: I guess this is off-topic, but - 

Peeved 1: 
Yes, I noted with a 'humph' that some F-MX ActionScript has altered, but never mind, it was only scripts I use regularly that changed!  

Peeved 2: 
As for Director, I spent £900 on the thing last year only to find it couldn't save projectors for CDs as cross-platform. I didn't think to ask and had to read the manual to find that out. 

Yippee for F-MX although there seem to be minor problems supporting Quicktime movies due to their length.

I wish BlingBling success with his audio.


----------

