player não desliza o botão
Olá galera, tudo bem ?
Bom estou com um problema em um player q fiz, seguinte, o botão que coloquei na barra carregamento das musicas, não quer deslizar, quando é arrastado.
Queria que ele fosse arrastado e quando fosse solto ele tocasse a música a partir da posição do botão. Ele até já faz isso mas só quando eu clico na barra, ai ele vai para a posição onde o mouse clicou na barra, mas não pode ser arrastado.
Se alguém quiser o arquivo FLA. é so me falar.
abaixo tem o código do player, se alguém puder me ajudar, ficarei muito grato.
////////// RELÓGIO TEMPO ////////////////////
formatTime = function (millisecs) {
var secs = Math.floor(millisecs/1000);
var mins = Math.floor(secs/60);
secs %= 60;
if (secs<10) {
secs = "0"+secs;
}
if (mins<10) {
mins = "0"+mins;
}
return mins+":"+secs;
};
////////// MOVIE CLIP VAZIO /////////////////
var snd = this.createEmptyMovieClip("SoundController", 1);
snd.loadSound = function(url) {
this._sound.loadSound(url, true);
snd._sound.stop();
this.updateTime();
};
snd.updateTime = function() {
var time = formatTime(snd.position);
if (time_txt.text != time) {
time_txt.text = time;
}
};
snd._sound.onSoundComplete = function() {
snd._sound.stop();
};
function iniciar() {
snd.onEnterFrame = function() {
if (this.isPlaying) {
this.position = this._sound.position;
}
this.loaded = this._sound.getBytesLoaded()/this._sound.getBytesTotal();
loadingbar_mc._xscale = scrubber_mc._xscale*this.loaded;
_root.bt_arrasta._x = loadingbar_mc._xscale*this.position/this._sound.duration+38.5;
progressbar_mc._xscale = loadingbar_mc._xscale*this.position/this._sound.duration;
this.updateTime();
if ((this.position/this._sound.duration) == 1) {
this._sound.stop();
this.isPlaying = false;
progressbar_mc._xscale = 0;
this.position = 0;
play_btn.gotoAndStop(1);
_root.gotoAndPlay(11);
_root.somanima_mc.gotoAndStop(1);
_root.C._x = 38.5;
}
};
}
snd.init = function() {
snd._sound = new Sound(this);
this.isPlaying = true;
this.position = 0;
loadingbar_mc._xscale = 0;
progressbar_mc._xscale = 0;
};
////////////// BOTÃO PLAY E PAUSE
play_btn.onPress = function() {
if (!isPlaying && this._currentframe == 2) {
if (!snd.isPlaying) {
return (0);
}
snd.position = snd._sound.position;
snd._sound.stop();
snd.isPlaying = false;
this.gotoAndStop(1);
_root.gotoAndPlay(11);
_root.somanima_mc.gotoAndStop(1);
_root.somanima_mc.gotoAndStop(1);
} else {
iniciar();
snd._sound.start(snd.position/1000);
snd.isPlaying = true;
_root.gotoAndPlay(2);
this.gotoAndStop(2);
_root.somanima_mc.gotoAndPlay(2);
}
};
////////// SCROLL ////////////
scrubber_mc.onRelease = scrubber_mc.onReleaseOutside=function () {
if (!snd.loaded) {
return (0);
}
var pos = this._xmouse/100;
snd.position = Math.min(snd._sound.duration, pos*snd._sound.duration/snd.loaded);
snd._sound.start(snd.position/1000);
_root.bt_arrasta.stopDrag();
snd.isPlaying = true;
};
scrubber_mc.onPress = function() {
_root.bt_arrasta.startDrag(false, 38.5, 12.15, 200, 12.15);
_root.bt_arrasta._x = null;
snd.position = snd._sound.position;
snd._sound.stop();
snd.isPlaying = false;
};
SetSong = function (node) {
snd.node = node;
snd.loadSound(node);
};
snd.init();
////////////// FUNÇÃO QUE CHAMA A MÚSICA ///////////////
GenerateSongListing = function (target_mc) {
target_mc = target_mc.createEmptyMovieClip("list_mc", 1);
var songs = "arquivo.mp3";
var song_mc = target_mc.attachMovie("song", "song"+i, i);
song_mc.node = songs;
SetSong(song_mc.node);
};
GenerateSongListing(playlist_mc);
abs a todos.
Discussão (1)
Carregando comentários...