开发者

Flash AS2: setting playheadTime of MediaPlayback component

I'm building a custom Audio Player. The whole thing drives a MediaPlayback component. I have a scrubber set up that moves with the progress of the song. I want to be able to click and scrub with it though. Currently I have it set to set the playheadTime equal to the percent distance the slider is dragged to times the totalTime of the playback component. After the release of the slider I trace out the playheadTime and it seems to be fi开发者_运维知识库ne, but I can't get it to resume playing at all. Here's the code in the controller:

var totalDistance = bar_mc._width - slider_mc._width;
var wasPlaying = false;
this.onEnterFrame = function(){
    var tTime = this._parent._parent._parent.music_mp3.totalTime;
    var cTime = this._parent._parent._parent.music_mp3.playheadTime;
    var percDone = cTime / tTime;
    slider_mc._x = percDone * totalDistance;
}
slider_mc.onPress = function(){
    wasPlaying = this._parent._parent._parent._parent.music_mp3.playing;
    this._parent._parent._parent._parent.music_mp3.pause();
    this.startDrag(false,0,0,totalDistance,0);
    delete this._parent.onEnterFrame;
    this.onEnterFrame = function(){
          this._parent._parent._parent._parent.music_mp3.playheadTime = this._x / totalDistance * this._parent._parent._parent._parent.music_mp3.totalTime;
    }
}
slider_mc.onRelease = slider_mc.onReleaseOutside = function(){
    this.stopDrag();
    if(wasPlaying){
            this._parent._parent._parent._parent.music_mp3.play();
            trace(this._parent._parent._parent._parent.music_mp3.playheadTime);
    }
    this._parent.onEnterFrame = function(){
            var tTime = this._parent._parent._parent._parent.music_mp3.totalTime;
            var cTime = this._parent._parent._parent._parent.music_mp3.playheadTime;
            var percDone = cTime / tTime;
            slider_mc._x = percDone * totalDistance;
    }
}


wow, I'm dumb. I just realized I'm setting the playheadtime to the current position in an onEnterFrame. Then in the onRelease I don't remove that reference so it's just going to constantly set the playhead time to the point at which i've dragged the scrubber's position.

need a delete this.onEnterFrame in the slider_mc.onRelease.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜