-
Sound does not play just once
I tried modifying the sound in Action Script but now I do not get any sound on the webpage, only hear the sound in preview on flash editor.
It was looping sound on the web page and I did not want to have surfers having to hit the stop button. But I did want it to play just once.
Here is the code I have now
// constants
var numtrack:Number = 1;
var maxTracks:Number = 3;
var _sound:Sound = new Sound();
var _volume:Number = 50;
var maxVolume:Number = 100;
var minVolume:Number = 0;
var maxVolumeWidth:Number = maskVolume._width;
var endVolX:Number = this._x+maskVolume._x+maskVolume._width;
maskVolume._width = maskVolume._width*_volume/100;
//
_sound.onLoad = function(success:Boolean) {
if (success) {
_sound.setVolume(_volume);
_sound.start();
clearInterval(interval);
txtLoading.text = "";
}
};
function loader(_sound) {
var gbl = _sound.getBytesLoaded();
var gbt = _sound.getBytesTotal();
txtLoading.text = "track "+numtrack+" loading "+int(gbl/gbt*100)+"%";
}
interval = setInterval(loader, 100, _sound);
_sound.loadSound("music/shiny-ding.mp3", false);
_sound.onSoundComplete = function() {
stopAllSounds();
}
//
//------------------ setVolume -------------------------/
function setNewVolume() {
maskVolume._width = maxVolumeWidth+_root._xmouse-endVolX;
_volume = Math.floor(maskVolume._width*100/maxVolumeWidth);
if (_volume<0) {
_volume = 0;
}
if (_volume>100) {
_volume = 100;
}
_sound.setVolume(_volume);
}
var mouseListenerVolume:Object = new Object();
mouseListenerVolume.onMouseDown = function() {
if (controlVolume.hitTest(_root._xmouse, _root._ymouse)) {
onEnterFrame = function () {
setNewVolume();
};
}
};
mouseListenerVolume.onMouseUp = function() {
delete onEnterFrame;
};
Mouse.addListener(mouseListenerVolume);
//
//-----------------player controls---------------------//
btnNext.onRelease = function() {
numtrack++;
if (numtrack>maxTracks) {
numtrack = 1;
}
_sound.loadSound("music/track"+numtrack+".mp3", false);
interval = setInterval(loader, 100, _sound);
};
btnPrev.onRelease = function() {
numtrack--;
if (numtrack == 0) {
numtrack = maxTracks;
}
_sound.loadSound("music/track"+numtrack+".mp3", false);
interval = setInterval(loader, 100, _sound);
};
btnStop.onRelease = function() {
_sound.stop();
};
btnPlay.onRelease = function() {
_sound.stop();
_sound.start();
};
btnNext.onRollOver = btnPrev.onRollOver=btnStop.onRollOver=btnPlay.onRo llOver=function () {
this.gotoAndPlay("over");
};
btnNext.onRollOut = btnPrev.onRollOut=btnStop.onRollOut=btnPlay.onRoll Out=function () {
this.gotoAndPlay("out");
};
btnNext.onReleaseOutside = btnPrev.onReleaseOutside=btnStop.onReleaseOutside= btnPlay.onReleaseOutside=function () {
this.gotoAndPlay("out");
};
Thanks, I am sure it is missing something I just do not see it.
-
Prid - Outing
For starter, are you sure the music files are in your server, located in the music/track folder? And I can't AS3, only AS2, so I'm sorry, but I can't help you with the just play once music.
What you could do however, is to import your own small beat, or the one you got with the template, and click on the Frame you'd like it to play once, and then open up Properties Panel, drag the Music file on Stage from Library, and then click on the Event/Loop button in Properties panel, and select Event, and on the next one, Repeat, and on the last field, type 1. This will make the music only play once, but for the users to manually play the music again, I'm sorry, but I can't help you with AS3
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|