Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 18-08-2004, 12:13   #1 (permalink)
aussenseiter
 
Registriert seit: Aug 2004
Ort: Frankfurt
Beiträge: 34
Lightbulb Formel für die Sternzeit in AS

hab die formel in JS und in PHP nur die in Flash hinzukriegen is mir nich gelungen

hat sie jemand schon gemacht?

PHP-Code:
// Sternzeit
function SGN(x) {
    if (
x<0) {
        
= -1;
    }
    if (
== 0) {
        
0;
    }
    if (
x>0) {
        
1;
    }
    return 
y;
}
function 
is_leap_year(year) {
    
JG year;
    
JJ JG-floor(JG/100)*100;
    
JH JG-JJ;
    return 
SGN(JG%100)-SGN(JJ%4)+1-SGN(JG%400);
}
function 
day_of_year(yearmonthday) {
    
days_in_month_data = new Array("31,28,31,30,31,30,31,31,30,31,30,31"

"31,29,31,30,31,30,31,31,30,31,30,31");
    
days_in_month $days_in_month_data[is_leap_year(year)];
    for (
i=1i<monthi++) {
        
day += days_in_month[i];
    }
    return 
day;
}
function 
sternzeit(yearmonthdayhourminutesecond) {
    
datum = new Date();
    var 
day;
    var 
month;
    var 
year;
    var 
hour;
    var 
minute;
    var 
second;
    
year datum.getFullYear();
    
month datum.getMonth()+1;
    
day datum.getDate();
    
hour datum.getHours();
    
minute datum.getMinutes();
    
second datum.getSeconds();
    
daysinyear 365+is_leap_year(year);
    
dayofyear day_of_year(yearmonthday)+1;
    
thestardate 

round(((year-1989)+((dayofyear+(hour/24)+(minute/1440)+(second/86400))/daysinyear))*100000)/100;
    return 
thestardate;

so dacht ich es würde es funzen... funzt aber nitt... arbeite erst seid 2 wochen mit flash intensive... daher müsster meine dummheit entschuldigen wenn die syntax garnicht funzen kann *gggggggg*

das original script in php ist

PHP-Code:
function SGN($x) {
  if (
$x 0$y = -1;
  if (
$x == 0$y 0;
  if (
$x 0$y 1;
  return 
$y;
}

function 
is_leap_year($year) {
  
$JG $year;
  
$JJ $JG floor($JG/100)*100;
  
$JH $JG $JJ;
  return 
SGN($JG 100) - SGN($JJ 4) + SGN($JG 400);
}

function 
day_of_year($year,$month,$day) {
  
$days_in_month_data    =    array(
    
0    =>    array(31,28,31,30,31,30,31,31,30,31,30,31),
    
1    =>    array(31,29,31,30,31,30,31,31,30,31,30,31)
  );
  
$days_in_month $days_in_month_data[is_leap_year($year)];
  for (
$i=1;$i<$month;$i++) {
    
$day += $days_in_month[$i];
  }
  return 
$day;
}

function 
stardate($year false$month false$day false$hour false$minute false$second false)
  {
    
$timestamp    =    time();
    
$thistime    =    getdate($timestamp);

    if (empty(
$year))    $year    =    $thistime["year"];
    if (empty(
$month))    $month    =    $thistime["mon"];
    if (empty(
$day))    $day    =    $thistime["mday"];
    if (empty(
$hour))    $hour    =    $thistime["hours"];
    if (empty(
$minute))    $minute    =    $thistime["minutes"];
    if (empty(
$second))    $second    =    $thistime["seconds"];

    
$daysinyear    =    365 is_leap_year($year);
    
$dayofyear    =    day_of_year($year,$month,$day) + 1;

    
$thestardate round((($year-2323)+(($dayofyear+($hour/24)+($minute/1440)+($second/86400))/$daysinyear))*100000)/100;

    return 
$thestardate;
  } 
wäre schön wenn sich einer die zeit nimmt mir zu helfen...
Sebb ist offline   Mit Zitat antworten
Alt 18-08-2004, 13:58   #2 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Hi.
Sieht für mich alles ziemlich unbegreiflich aus.
Aber 3 Sachen habe ich schon mal entdeckt.

Zeile 16 floor > sollte wohl Math.floor sein.
Zeile 24 Willst Du da nicht das Array days_in_month_data ansprechen?!
Zeile 44 round > sollte wohl Math.round sein.
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 18-08-2004, 16:25   #3 (permalink)
aussenseiter
 
Registriert seit: Aug 2004
Ort: Frankfurt
Beiträge: 34
Lightbulb

danke erstmal dasde dir die zeit genommen hast...

das mit den math. is schonmal sehr gut hab mit AS bisher nur das nötigste genutzt un das braucht ich nochnie... aber anscheinend jetzt... habs mir durchgelesen...

Zeile 24 Willst Du da nicht das Array days_in_month_data ansprechen?!

das tut es doch auch oder nicht?
Sebb ist offline   Mit Zitat antworten
Alt 18-08-2004, 16:29   #4 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Nein Du hast beim Array ansprechen das _data vergessen.
Bei Dir steht da nur days_in_month.
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 18-08-2004, 16:39   #5 (permalink)
aussenseiter
 
Registriert seit: Aug 2004
Ort: Frankfurt
Beiträge: 34
Lightbulb

sagmal spinn ich oder is AS und JS sich arsch ähnlich?

EDIT:

zeile 24:
day += days_in_month[i];

und die function days_in_month:
days_in_month = days_in_month_data[is_leap_year(year)];

Geändert von Sebb (18-08-2004 um 16:41 Uhr)
Sebb ist offline   Mit Zitat antworten
Alt 18-08-2004, 16:41   #6 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
AS und JavaScript sind nahezu gleich.
AS wird auch immer mehr angeglichen.
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 18-08-2004, 16:44   #7 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Sorry scheint doch richtig zu sein, mit dem Array.
Aber warum steht das $ vor dem $days_in_month_data[is_leap_year(year)];?
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 18-08-2004, 16:46   #8 (permalink)
aussenseiter
 
Registriert seit: Aug 2004
Ort: Frankfurt
Beiträge: 34
Lightbulb

job hab ich auch schon wegemacht... hattes am anfang vergessen wo ich den text editiert hab... aber trotzdem funzt es nochnet...

ich probiers mal mit der JS variante denn die kann ich wenigstens
Sebb ist offline   Mit Zitat antworten
Alt 18-08-2004, 16:46   #9 (permalink)
a.k.a maddin79
 
Benutzerbild von madflanderz
 
Registriert seit: Jul 2003
Ort: berlin f-hain
Beiträge: 1.693
na weils da nich hingehört :-)
__________________
www.madflanderz.de

ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°` _ addicted to bass _ `°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø
madflanderz ist offline   Mit Zitat antworten
Alt 18-08-2004, 16:54   #10 (permalink)
aussenseiter
 
Registriert seit: Aug 2004
Ort: Frankfurt
Beiträge: 34
Exclamation

muha, habs geschaft

is klasse das AS sich JS so ähnelt...

Sebb ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 12:01 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele