Slider und Zeitleistensteuerung

this.stop();
var isPlay = false;
var barWidth = 500;//Breite des Balkens im slider_mc Ganzzahl erforderlich

this.play_btn.addEventListener("click", playTimeline.bind(this));
this.pause_btn.addEventListener("click", pauseTimeline.bind(this));
this.slider_mc.slider_btn.addEventListener("mousedown", pauseTimeline.bind(this));
this.slider_mc.slider_btn.addEventListener("pressmove", dragMe.bind(this));
this.slider_mc.slider_btn.addEventListener("tick", moveSlider.bind(this));

function dragMe(evt) {
	var evTg = evt.currentTarget;
	var p = this.slider_mc.globalToLocal(evt.stageX, evt.stageY);
	evTg.x = p.x;
	if (evTg.x < 0) {
		evTg.x = 0;
	} else if (evTg.x > barWidth) {
		evTg.x = barWidth;
	}
	var fkt = evTg.x/barWidth //Faktor zwischen 0 und 1
	this.gotoAndStop(Math.floor(this.totalFrames * fkt));
}


function playTimeline(){
	isPlay = true;
	this.play();
	this.play_btn.visible = false;
	this.pause_btn.visible = true;
}


function pauseTimeline(){
	isPlay = false;
	this.stop();
	this.play_btn.visible = true;
	this.pause_btn.visible = false;
}

function moveSlider(evt){
	if(isPlay){
	var aniFaktor = barWidth / this.totalFrames;	
	evt.currentTarget.x = this.currentFrame * aniFaktor;
	}
}
	

weiter