Parapal Design Flash

A A A Text size

Actionscript source code and FLA files

Flash mp3 player (normal and mini version).

Download mp3 fla

Main timeline script

//Code to control position of the slider, s is the sound object

src = "mysong.mp3";
this.onEnterFrame = function() {
goTime = s.position/1000;
if (_root.dragging == false) {
_root.slider.knob._y = _root.slider.knob.left-(((goTime*1000)/s.duration)*100)+100; //works out position of slider while playing
} else if (_root.dragging == true) {
s.stop();
goTime = ((100-(_root.slider.knob._y-_root.slider.knob.left))/100000)*s.duration; //works out position of sound when dragging slider
s.start(goTime);
if (_root.playing == false) {
s.stop();
}
}
};

//loads and stops the sound
s = new Sound();
s.loadSound(src, true);
s.stop();

//sets up main variables
_root.playing = false;
_root.dragging = false;
_root.playButton.onPress = function() {
s.start(goTime);
_root.playButton._visible = false;
_root.playing = true;
};
_root.pausebutton.onPress = function() {
_root.playButton._visible = true;
goTime = s.position;
_root.playing = false;
s.stop();
};
_root.rewind.onPress = function() {
_root.playButton._visible = true;
_root.playing = false;
goTime = 0;
s.start(goTime);
s.stop();
};