Hi There,
I followed the Kirupa tutorial about ‘Creating a Volume Control Slider’ which was great and worked fine, but I would like the mp3 to start playing at a moderate volume as soon as the user enters the site, at the moment you have to press play and then adjust the slider.
Thanks in advance
Just assign a default volume within the onLoad event, e.g.
onClipEvent (load) {
mySound = new Sound();
mySound.loadSound("sound2.mp3", false);
//set the default volume to whatever you want here
_root.volume = 50;
}
You might also want to reflect the default volume setting on the slider, in which case also add the following line after where you’ve changed the volume:
dragger._x = line._width*_root.volume/100;
I’m not quite sure, since I’ve changed the solution from the tutorial somewhat, but i think the following does the trick (let me know):
Add red Script !
1.in the ActionScript in the main scene:
onClipEvent (load) {
mySound_1 = new Sound();
mySound_1.loadSound(“sound_1.mp3”, false);
[COLOR=red] _root.volume = 70;[/COLOR]
[COLOR=#ff0000][/COLOR]
[COLOR=#ff0000][/COLOR]
[COLOR=black]2. In the ActionScript in the movieclip “slider”:[/COLOR]
[COLOR=black]ratio = Math.round(this._x100/line._width);
_root.volume = ratio;
};
};
[COLOR=red]dragger._x = line._width_root.volume/100;[/COLOR] [/COLOR]
[COLOR=black]dragger.onRelease = dragger.onreleaseOutside=stopDrag;[/COLOR]
That’s it, hopefully :beer2:
Greetings, Romanoff
[COLOR=#ff0000][/COLOR]
[quote=romanoff;2358393]I’m not quite sure, since I’ve changed the solution from the tutorial somewhat, but i think the following does the trick (let me know):
Add red Script !
1.in the ActionScript in the main scene:
onClipEvent (load) {
mySound_1 = new Sound();
mySound_1.loadSound(“sound_1.mp3”, false);
[COLOR=red] _root.volume = 70;[/COLOR]
[COLOR=black]2. In the ActionScript in the movieclip “slider”:[/COLOR]
[COLOR=black]ratio = Math.round(this._x100/line._width);
_root.volume = ratio;
};
};
[COLOR=red]dragger._x = line._width_root.volume/100;[/COLOR] [/COLOR]
[COLOR=black]dragger.onRelease = dragger.onreleaseOutside=stopDrag;[/COLOR]
That’s it, hopefully :beer2:
Greetings, Romanoff
[/quote]
great thanks that sorts out the volume level:beer2:, what script do I use to have the sound playing as soon as the user enters the page at present you have to click the play button for the music to start?
[quote=glosrfc;2358390]Just assign a default volume within the onLoad event, e.g.
ActionScript Code:
[LEFT][COLOR=#0000FF]onClipEvent[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
mySound = [COLOR=#000000]new[/COLOR] [COLOR=#0000FF]Sound[/COLOR]COLOR=#000000[/COLOR];
mySound.[COLOR=#0000FF]loadSound[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“sound2.mp3”[/COLOR], [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#808080]//set the default volume to whatever you want here[/COLOR]
_root.[COLOR=#000080]volume[/COLOR] = [COLOR=#000080]50[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
You might also want to reflect the default volume setting on the slider, in which case also add the following line after where you’ve changed the volume:
ActionScript Code:
[LEFT]dragger.[COLOR=#0000FF]_x[/COLOR] = line.[COLOR=#0000FF]_width[/COLOR]*[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]volume[/COLOR]/[COLOR=#000080]100[/COLOR];
[/LEFT]
[/quote]
Thanks glosrfc! IF I want the music to play as soon a user enters the site do I need to change the ‘false’ part to ‘true’? thx
mySound.[COLOR=#0000FF]loadSound[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“sound2.mp3”[/COLOR], [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR];
Thanks for all your help guys, much appreciated, managed to suss out the mp3 playing when user enters the page, but now the mp3 doesn’t loop?
Whereas it did previously??
Do I need an extra piece of code to get the mp3 to loop?
thanks