Funktion wird nur einmal aufgerufen

Rollo

Erfahrenes Mitglied
Hallo Liebe Tutorials-Nutzer,
ich abe seit langem mal wieder ein Problem, für das ich keinen Lösungsansatz weiß. Ich habe vor Kurzem einen MP3 Player auf XML Basis anhand eines Tutorials programmiert. So weit so gut. Alles funktioniert, bis auf Folgendes.

Immer wenn ein Song beginnt, wird eine Funktion namens sound_starten aufgerufen. In dieser wird eine weitere Funktion aufgerufen, songtitel. Doch diese wird scheinbar nur beim ersten Song aufgerufen.

Was kann ich tun, das die Funktion Songtitel beim Liedwechsel aufgerufen wird? Muss diese zurückgesetzt werden? Oder gibt es einen offensichtlichen Fehler?

Anbei die Funktion sound_starten und dei Funktion songtitel:
Code:
MovieClip.prototype.sound_starten = function(file, name, band) {
	this.sound_obj.loadSound(file,true);

	this.onEnterFrame = function() {
		if (this.sound_obj.position>0) {
			delete this.onEnterFrame;
			/* Aufruf des Songtitels */
			_root.songtitel(name,band);
		} else {
			trace('loading...');
		}
	};


	/* Wenn Song abgespielt ist */
	this.sound_obj.onSoundComplete = function() {
		(song_nr == songnamen.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.sound_starten(songfiles[song_nr],songnamen[song_nr],songband[song_nr]);

	};

};

Code:
this.songtitel_mc._alpha = 0;
function songtitel(titel, band) {

	_root.songtitel_mc.starttext.text = "GL Player 2.0";
	_root.songtitel_mc.songtitel.text = titel;
	_root.songtitel_mc.band.text = band;

	this.songtitel_mc.onEnterFrame = function() {
		if (_root.songtitel_mc._alpha<=100) {
			_root.songtitel_mc._alpha += (_root.songtitel_mc._alpha+4)/5;
		} else {
			_root.songtitel_mc._alpha = _root.songtitel_mc._alpha;
			setInterval(playBackFalse,3000);
		}
	};

	function playBackFalse() {
		_root.songtitel_mc.playback = false;
		setInterval(alphaAufNull,7000);
	}
	function alphaAufNull() {
		_root.songtitel_mc.onEnterFrame = function() {
			if (_root.songtitel_mc._alpha>=0) {
				_root.songtitel_mc._alpha -= (_root.songtitel_mc._alpha)*0.2;
				trace(_root.songtitel_mc._alpha);
			} else {
				_root.songtitel_mc._alpha = _root.songtitel_mc._alpha;
				_root.songtitel_mc.playback = true;
			}
		};
	}
}

Für jede Antwort bedanke ich mich schon einmal im Voraus.

Grüße,
Rollo
 
Hallo nochmal,
ich habe es selbst hinbekommen. Aber um diesen Beitrag zu vervollständigen stelle ich noch die Lösung mit rein. Der Fehler war in der songtitel Funktion. Hier das funktionierende Ergebnis:

Code:
_global.songtitel = function(titel, band) {
	
	_root.songtitel_mc.songtitel = "";
	_root.songtitel_mc.band = "";

	_root.songtitel_mc.starttext = "GL Player 2.0";
	_root.songtitel_mc.songtitel = titel;
	_root.songtitel_mc.band = band;

	_root.songtitel_mc.onEnterFrame = function() {
		if (_root.songtitel_mc._alpha<=100) {
			_root.songtitel_mc._alpha += (_root.songtitel_mc._alpha+4)/5;
		} else {
			_root.songtitel_mc._alpha = _root.songtitel_mc._alpha;
			pF = setInterval(playBackFalse, 2000);
			delete _root.songtitel_mc.onEnterFrame;
		}
	};

	function playBackFalse() {
		clearInterval(pF);
		_root.songtitel_mc.playback = false;
		aAN = setInterval(alphaAufNull, 6000);
	}
	function alphaAufNull() {
		clearInterval(aAN);
		_root.songtitel_mc.starttext = "";
		_root.songtitel_mc.onEnterFrame = function() {
			if (_root.songtitel_mc._alpha>=0) {
				_root.songtitel_mc._alpha -= (_root.songtitel_mc._alpha)*0.2;
				_root.songtitel_mc.playback = true;
			} else {
				_root.songtitel_mc._alpha = _root.songtitel_mc._alpha;
				delete _root.songtitel_mc.onEnterFrame;
			}
		};
	}
};
 

Neue Beiträge

Zurück