Stoppuhr ab bestimmter Zeit [MX]

schwarzfahrer

Gesperrt
Hallo zusammen,

an die, die schonmal reingekuckt haben: Ja ich hab den Beitrag völlig überarbeitet :rolleyes: genau wie das .fla um das es geht.

Ich habe eine Stoppuhr die das Zählen anfängt wenn die Datei aufgerufen wird.

Es soll eine Art Fake-Uhr sein, deshalb startet sie auch um 13:12:00

Soweit so gut!

Ich möchte das zu einer bestimmten Uhrzeit ein anderer Frame geladen wird, bzw. in einem Movieclip ein anderer Frame geladen wird.

Der Aufruf sieht bei mir so aus:

if (atime[0]==14 && atime[2]==13 && atime[4] {
meinmovie.gotoAndStop(2)
meinmovie2.gotoAndPlay(2);
}

Er funktioniert nicht.

Vielleicht ist es das Beste wenn ich meinen ganzen Code dazuposte (überarbeitet und gekürzt, kommt aber von flashkit.com):

Danke, danke, danke schonmal an alle die sich die Mühe machen!

Code:
// atime = [00, 11, 22, 33, 44, 55, 66}
// atime = [hh, XX, mm, XX, ss, XX, 00)
// initialize the array
atime = new Array();
atime[0] = "13";
atime[1] = ":";
atime[2] = "12";
atime[3] = ":";
atime[4] = "00";
function timerFunk () {
	// used for the pause button... sets the freexe time to the current clock time
	// pickup is set to 1 within the pause frame, once this "if" statment runs,
	// the pause setting is turned off so that this "if" statement doesn't execute again
	if (pickup) {
		freeze = microtime;
		pickUp = 0;
	}
	// this resets the clock back to "0" then disables this feature
	// by setting "reset" to 0
	if (reset) {
		freeze = 0;
		time = atime.join("");
		reset = 0;
	}
	// this is the meat and potatoes... initilized at the root of the frame
	if (timerOn) {
		// "stamp" the current time, then disable this feature by setting
		// "check" to "0"
		if (check) {
			timeBase = getTimer();
			check = 0;
		}
		// timenow is constantly updated here
		timeNow = getTimer();
		// the difference between timeNow and timeBase is determined,
		// plus we are throwing in the "freeze" variable for when
		// the clock is in the "pause" mode... during normal operation,
		// freeeze is set to "0" so it is a nice way to gain the pause function
		// with just a little bit of code
		microtime = (Number(timeNow)-Number(timeBase)+Number(freeze));
		// "mts" stand for MicroTime seconds, since here we are mainly interested in
		// deriving the seconds... We convert "mts" t a string so that we can "split"
		// it on the "." (the "." appears because we have devided the milliseconds by 1000
		// 
		// after this statement "mts" magically turns into an array (due to the "split"
		// function. So later on you will see things like mts[0] and mts[1]... mts[0] is the junk
		// on the left hand side of the "." and mts[1] is the junk from the right hand side of the "."
		mts = (microtime/1000).toString().split(".");
		// when mts gets to 60 we reset the clock simply by turning "check" "on"
		// "check" get turned off after one iteration above
		if (mts[0]>59) {
			check = 1;
		}
		// 
		// here we are populating the sixth element of the array with the right hand
		// side of the mts array ( aka:   mts[1]   ) then chopping off all but the first 3 characters
		// via the substr() function
		// 
		atime[4] = mts[1].substr(0, 1);
		if (atime[4].toString().length<1) {
			atime[4] = "0";
		}
		// 
		// here we are populating the 4th element of the atime array with the junk from the left hand side
		// of the mts array
		// 
		atime[4] = mts[0];
		// here we ensure that the display always contains two characters
		if (atime[4].toString().length<2) {
			atime[4] = "0" add atime[4];
		}
		if (atime[4].toString().length<1) {
			atime[4] = "00";
		}
		// since we've know that the left hand side of mts is "seconds" and that we have put
		// mts[0} into the 4th element of the atime array - they are the same thing... so when our "seconds" get to
		// 60 (since this will execute only when mts[0] gets to 60... we bump the minutes up by one increment
		// then reset the display (atime[4]) to "00"
		// 
		if (atime[4]>59) {
			atime[2] = Number(atime[2])+Number(1);
			atime[4] = "00";
		}
		
		// here we ensure that the display always contains two characters
		if (atime[2].toString().length<2) {
			atime[2] = "0" add atime[2].toString();
		}
		// bump the hours up when atime[2] (minutes) reaches 60
		if (atime[2]>59) {
			atime[0] = Number(atime[0])+Number(1);
			atime[2] = "00";
		}
		// here we ensure that the display always contains two characters
		if (atime[0].toString().length<2) {
			atime[0] = "0" add atime[0];
		}
		if (atime[0].toString().length<1) {
			atime[0] = "00";
		}
		// extract the data out of the atime array and smoosh it all together
		// then display it in the text field on the stage
		time = atime.join("");
	}
}
 
Zuletzt bearbeitet:
Hi,

ich muss gestehen, ich habe mir dein Script jetzt nicht ganz durchgelesen (denn ich mag auch vorgefertigte Scripts nicht so gerne :))...
aber mit 2-3 benutzerdefinierten Funktionen ist es eigentlich kein Problem
Im Anhang findest Du ein kleines .fla (MX) von mir, in dem die aktuelle Uhrzeit im oberen Textfeld angezeigt wird - im unteren Textfeld kannst Du die "Endzeit" eingeben (muss im Format hh:mm:ss sein, da der Doppelpunkt als Seperator verwendet wird).
Sobald die Uhr die "Endzeit" erreicht, wird eine Trace-Aktion ausgelöst (sprich: die Funktion "fire" - da kannst Du dann reinschreiben, was Du willst).

Gruß

P.S.: Du kannst natürlich jede beliebige Zeit als Startzeit nehmen, in dem Fall eben nicht das Date-Objekt benutzen, sondern die Variablen "hour", "minute" und "second" per Hand setzen.
 

Anhänge

  • stoppuhr.zip
    3,5 KB · Aufrufe: 60
Zuletzt bearbeitet:
Hoi hoi,

danke für die Antwort und des File... aber das geht irgendwie in eine ganz andere Richtung. Ich hänge mal mein File an den Beitrag, dann erübrigt sich das Quelltext lesen im Forum.

Was mir hier noch fehlt ist wie gesagt eigentlich "nur noch" das zu einer bestimmten Uhrzeit etwas passiert wie:
Code:
meinmovie.gotoAndStop(2)

Mit meinem Aufruf aus dem 1. Posting klappt es nicht.

Nochmal, danke danke :rolleyes:
 

Anhänge

  • stoppuhrsf.zip
    5,4 KB · Aufrufe: 32
Hi,

Soweit ich das sehen kann, macht Dein Script auch nichts anderes als meins...

Jedenfalls habe ich in Dein Script an den Anfang der Funktion "timerFunc" folgende Anfrage gesetzt:
PHP:
if (int(atime[0])==13 && int(atime[2])==12 && int(atime[4])==20) {
    trace("DONE");
}
Jetzt wird die Trace-Aktion z.B. um 13:12:20 aufgerufen.
Ersetze das "Trace" durch z.B.
PHP:
_root.gotoAndPlay(20);
und füge noch ein
PHP:
timerOn=false;
ein (um die Uhr dann anzuhalten).

Nun müsste es funktionieren.

Gruß
 
Zurück