ok i have a sort of MP3 player that i have made in flash, i have 2 songs, i have a play, stop, fast forward, rewind, skip forward and rewind button on the main bar, i have a bar showing what the song is and i also have a volume slider and a bar with a slider that shows the position of the song. you can move the slider to a different part of the song, but what i need is to be able to add in some AS that would enable me to click a place on the bar that shows the position of the song, then the AS works out where on the line you have pressed and then move the song and slider to that point. here is my code for the hole MP3 player excluding the volume slider :
hip = true;
mysound = new Sound();
mysound.attachSound("song");
ms = new Sound();
ms.attachSound("song2");
mysound.start();
can = true;
startPosition = _root.progSlider._x;
left = _root.progSlider._x;
top = _root.progSlider._y;
right = _root.progBar._x+_root.progBar._width-7;
bottom = _root.progSlider._y;
onEnterFrame = function () {
if (can) {
_root.thing.gotoAndStop(1);
} else {
_root.thing.gotoAndStop(2);
}
mysound.onSoundComplete = function() {
can = false;
cn = false;
ms.start();
};
ms.onSoundComplete = function() {
can = true;
cn = false;
mysound.start();
};
_root.playe.onRelease = function() {
hip = true;
if (can) {
if (cn) {
mysound.start(myMusicPosition, 0);
} else {
mysound.start();
}
} else {
if (bn) {
ms.start(mmp, 0);
} else {
ms.start;
}
}
};
_root.sto.onRelease = function() {
hip = false;
stopAllSounds();
mmp = 0;
myMusicPosition = 0;
cn = false;
can = true;
};
_root.pause.onRelease = function() {
if (can) {
myMusicPosition = _root.mysound.position/1000;
_root.mysound.stop();
cn = true;
} else {
mmp = _root.ms.position/1000;
_root.ms.stop();
bn = true;
}
};
_root.skipfwd.onRelease = function() {
if (can) {
can = false;
cn = false;
mysound.stop();
ms.start();
} else {
can = true;
ms.stop();
mysound.start();
}
};
_root.skipbk.onRelease = function() {
if (can) {
mysound.stop();
mysound.start();
} else {
ms.stop();
ms.start();
}
};
if (hip) {
if (can) {
if (REV == 1 && myMusicPosition>0) {
_root.mysound.stop();
myMusicPosition = myMusicPosition-.5;
_root.mysound.start(myMusicPosition, 0);
}
revButton.onPress = function() {
REV = 1;
myMusicPosition = _root.mysound.position/1000;
};
revButton.onRelease = function() {
REV = 0;
};
revButton.onReleaseOutside = function() {
REV = 0;
};
if (FF == 1 && _root.mysound.position<_root.mysound.duration) {
_root.mysound.stop();
myMusicPosition = myMusicPosition+.5;
_root.mysound.start(myMusicPosition, 0);
}
FFButton.onPress = function() {
FF = 1;
myMusicPosition = _root.mysound.position/1000;
};
FFButton.onRelease = function() {
FF = 0;
};
FFButton.onReleaseOutside = function() {
FF = 0;
};
} else {
if (REVe == 1 && mmp>0) {
_root.ms.stop();
mmp = mmp-.5;
_root.ms.start(mmp, 0);
}
revButton.onPress = function() {
REVe = 1;
mmp = _root.ms.position/1000;
};
revButton.onRelease = function() {
REVe = 0;
};
revButton.onReleaseOutside = function() {
REVe = 0;
};
if (FFe == 1 && _root.ms.position<_root.ms.duration) {
_root.ms.stop();
mmp = mmp+.5;
_root.ms.start(mmp, 0);
}
FFButton.onPress = function() {
FFe = 1;
mmp = _root.ms.position/1000;
};
FFButton.onRelease = function() {
FFe = 0;
};
FFButton.onReleaseOutside = function() {
FFe = 0;
};
}
}
if (can) {
mySoundPosition = _root.mysound.position/1000;
mySoundDuration = _root.mysound.duration/1000;
myTimeBarPosition = startPosition+(mySoundPosition/mySoundDuration)*_root.progBar._width;
if (_root.dragingSlider != 1) {
_root.progSlider._x = myTimeBarPosition;
}
distanceTraveled = _root.progSlider._x-startPosition;
percentTraveled = distanceTraveled/_root.progBar._width;
dragStartPosition = percentTraveled*mySoundDuration;
_root.progSlider.onPress = function() {
_root.dragingSlider = 1;
_root.mysound.stop();
startDrag(_root.progSlider, false, left, top, right, bottom);
};
_root.progSlider.onRelease = function() {
_root.progSlider.stopDrag();
_root.dragingSlider = 0;
_root.mysound.start(dragStartPosition, 0);
};
} else {
mySoundPositio = _root.ms.position/1000;
mySoundDuratio = _root.ms.duration/1000;
myTimeBarPositio = startPosition+(mySoundPositio/mySoundDuratio)*_root.progBar._width;
if (_root.dragingSlide != 1) {
_root.progSlider._x = myTimeBarPositio;
}
distanceTravele = _root.progSlider._x-startPosition;
percentTravele = distanceTravele/_root.progBar._width;
dragStartPositio = percentTravele*mySoundDuratio;
_root.progSlider.onPress = function() {
_root.dragingSlide = 1;
_root.ms.stop();
startDrag(_root.progSlider, false, left, top, right, bottom);
};
_root.progSlider.onRelease = function() {
_root.progSlider.stopDrag();
_root.dragingSlide = 0;
_root.ms.start(dragStartPositio, 0);
};
}
};
the code that i am focusing on is the progBar & slider :
if (can) {
mySoundPosition = _root.mysound.position/1000;
mySoundDuration = _root.mysound.duration/1000;
myTimeBarPosition = startPosition+(mySoundPosition/mySoundDuration)*_root.progBar._width;
if (_root.dragingSlider != 1) {
_root.progSlider._x = myTimeBarPosition;
}
distanceTraveled = _root.progSlider._x-startPosition;
percentTraveled = distanceTraveled/_root.progBar._width;
dragStartPosition = percentTraveled*mySoundDuration;
_root.progSlider.onPress = function() {
_root.dragingSlider = 1;
_root.mysound.stop();
startDrag(_root.progSlider, false, left, top, right, bottom);
};
_root.progSlider.onRelease = function() {
_root.progSlider.stopDrag();
_root.dragingSlider = 0;
_root.mysound.start(dragStartPosition, 0);
};
} else {
mySoundPositio = _root.ms.position/1000;
mySoundDuratio = _root.ms.duration/1000;
myTimeBarPositio = startPosition+(mySoundPositio/mySoundDuratio)*_root.progBar._width;
if (_root.dragingSlide != 1) {
_root.progSlider._x = myTimeBarPositio;
}
distanceTravele = _root.progSlider._x-startPosition;
percentTravele = distanceTravele/_root.progBar._width;
dragStartPositio = percentTravele*mySoundDuratio;
_root.progSlider.onPress = function() {
_root.dragingSlide = 1;
_root.ms.stop();
startDrag(_root.progSlider, false, left, top, right, bottom);
};
_root.progSlider.onRelease = function() {
_root.progSlider.stopDrag();
_root.dragingSlide = 0;
_root.ms.start(dragStartPositio, 0);
};
}
if anyone could post back with the added code it would be realy helpfull.
thanks in advance :D:D
woopsedoo