Hi there–
First off, using Flash MX, so Actionscript 1.
I’m working on an audio player with a scrubbable playhead, per Kenny Bellew’s outstanding tutorials (http://www.kennybellew.com/tutorial/drag.htm). In order to learn the mechanics and test drive it, I was able to create a fully functional model in its own movie. Now I’m trying to apply it to an MC nested in a larger project and I’m having trouble.
The main website (w/o the audio part installed) is
www.someawfulbridge.com.
A smaller version that only has the part I’m working on (for this question) is
www.someawfulbridge.com/someawfulbridgeaudioonly.swf.
The songloading and play/pause/stop are working fine. (I’ll be adding a song loading preloader later–the songs are dynamically loaded), but I can NOT get the playhead working completely. It will track the progress of the song, but if dragged, the song stops, the playhead snaps back into its original place, and the song stops for good (until re-loaded).
Can anyone help me figure why this is? I’m betting I’m just calling something incorrectly–the whole Audio section is in the _root.Audio MC, and the songs are loaded in to audioSong.
The code for the drag head:
onClipEvent (load) {
startPosition= _root.Audio.hslider._x; // hslider is the knob.
left = _root.Audio.hslider._x;
top = _root.Audio.hslider._y;
right = _root.Audio.hbase._x+_root.Audio.hbase._width; //-7;
bottom = _root.Audio.hslider._y;
}
//
onClipEvent (enterFrame) {
//
mySoundPosition = _root.Audio.audioSong.position/1000;
mySoundDuration = _root.Audio.audioSong.duration/1000;
//
myTimeBarPosition = startPosition + (mySoundPosition/mySoundDuration) * _root.Audio.hbase._width;
if (_root.Audio.dragingSlider!=1) {
_root.Audio.hslider._x=myTimeBarPosition;
}
//
distanceTraveled = _root.Audio.hslider._x - startPosition;
percentTraveled = distanceTraveled / _root.Audio.hbase._width;
dragStartPosition = percentTraveled * mySoundDuration;
//
_root.Audio.hslider.onPress = function() {
_root.Audio.dragingSlider = 1;
_root.Audio.audioSong.stop();
startDrag(_root.Audio.hslider, false, left, top, right, bottom);
};
//
_root.Audio.hslider.onRelease = function() {
_root.Audio.hslider.stopDrag();
_root.Audio.dragingSlider = 0;
_root.audioSong.start(dragStartPosition, 0);
};
// Time Display
minutesTotal = Math.floor(mySoundDuration / 60);
secondsTotal = Math.floor(mySoundDuration-minutesTotal*60);
seconds = Math.floor((mySoundPosition)%60);
minutes = Math.floor((mySoundPosition)/60);
hours = Math.floor((mySoundPosition)/120);
//
_root.timeText01 = minutes + " : " + seconds;
_root.timeText02 = "/ " + minutesTotal + " : " + secondsTotal;
}// END
(Obviously this is “re-created” wholesale from the KB tut–credit where it’s due.)
Thanks for any help!
Mark