# Start sound immediately...?

**URL:** https://forum.kirupa.com/t/start-sound-immediately/65226
**Category:** Uncategorized
**Created:** [September 24, 2004, 6:05am UTC](https://forum.kirupa.com/t/start-sound-immediately/65226 "2004-09-24T06:05:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tanvi](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@tanvi](https://forum.kirupa.com/u/tanvi)
#### Post date: [September 24, 2004, 6:05am UTC](https://forum.kirupa.com/t/start-sound-immediately/65226/1 "2004-09-24T06:05:02Z")

</div>

[http://www.kirupa.com/developer/mx/volume\_slider.htm](http://www.kirupa.com/developer/mx/volume_slider.htm)

i am following these tuts but evrything is working fine but what i want is that my music should start playing immediately as it is loaded rather then waiting to click button to play…

so far i tried is:

[color=navy]onClipEvent (load) {  
mySound = new Sound();  
mySound.loadSound("\_jUsT-Rudy\_Ves-8003\_hifi.mp3", false);  
[/color] [color=darkorange]mySound.onLoad = playSound();  
function playSound(success) {  
if (success) {  
mySound.start();  
}  
[/color] [color=navy]}  
}  
onClipEvent (enterFrame) {  
downloaded = mySound.getBytesLoaded();  
total = mySound.getBytesTotal();  
if (downloaded != total) {  
\_root.dl = “downloading song…”;  
} else {  
complete = 1;  
\_root.dl = “playing”;  
}  
mySound.setVolume(\_root.volume\*2);  
}  
[/color]  
[color=black]where i a going wrong…???[/color]  
[color=black]help me[/color]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 24, 2004, 6:56am UTC](https://forum.kirupa.com/t/start-sound-immediately/65226/2 "2004-09-24T06:56:11Z")

</div>

Could this be?

```auto
onClipEvent (load) {
mySound = new Sound();
mySound.loadSound("_jUsT-Rudy_Ves-8003_hifi.mp3", false);
mySound.onLoad = playSound();
function playSound() {
mySound.start();
}

```

If that’s not working, my guess is that is not reaches the playSound function because the code gets executed only onload? ANd this line “mySound.onLoad = playSound();  
” when the sound is acctually loaded… isn’t invoked anymore…  
Put this line in your onClipEvent (enterFrame)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 24, 2004, 8:45am UTC](https://forum.kirupa.com/t/start-sound-immediately/65226/3 "2004-09-24T08:45:03Z")

</div>

> [@tanvi](#):
>
> [http://www.kirupa.com/developer/mx/volume\_slider.htm](http://www.kirupa.com/developer/mx/volume_slider.htm)
> 
> i am following these tuts but evrything is working fine but what i want is that my music should start playing immediately as it is loaded rather then waiting to click button to play…
> 
> so far i tried is:
> 
> [color=navy]onClipEvent (load) {  
> mySound = new Sound();  
> mySound.loadSound(“\_jUsT-Rudy\_Ves-8003\_hifi.mp3”, false);  
> [/color][color=darkorange]mySound.onLoad = playSound();  
> function playSound(success) {  
> if (success) {  
> mySound.start();  
> }  
> [/color][color=navy]}  
> }  
> onClipEvent (enterFrame) {  
> downloaded = mySound.getBytesLoaded();  
> total = mySound.getBytesTotal();  
> if (downloaded != total) {  
> \_root.dl = “downloading song…”;  
> } else {  
> complete = 1;  
> \_root.dl = “playing”;  
> }  
> mySound.setVolume(\_root.volume\*2);  
> }  
> [/color]  
> [color=black]where i a going wrong…???[/color]  
> [color=black]help me[/color]

Obviously your sound play just 'cause u’ve used the movieclip event handler. Try to load the sound from the first frame of the movie instead of assign that to the onLoad () event hanlder of movieclip.

```auto
 
_root.onLoad = function (){
//Your code goes here.
}

```

Assign the code for button on later to play the music.

```auto
 
/:mybutton.onRelease = function (){
mySound.start();
}
 

```

The onClipEnterFrame is, i hope, ok to check the downloading status of the sound…
