Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 03-02-2007, 09:16   #1 (permalink)
Neuer User
 
Registriert seit: Apr 2002
Beiträge: 96
Mondphasen-Script, Verbesserungen erwünscht :)

Hallo Forumler!

Ich bastel an einem simplen Mondphasen-Gadget. (Ja gibts scripte wie sand am Meer, aber kaum welche rein in AS)

Da ich programmiertechnisch ne Niete bin, hab ich folgendes Script erweitert
(Das Original-Script stammt von einem gewissen Jason Reeves, dessen webseite und email-adresse aber nicht mehr existent sind leider )

PHP-Code:
// at startup, fills variable based on today
function today() {
    
now = new Date();
    
currdate now.getDate();
    
_root.day currdate;
    
now.getMonth();
    
_root.month n+1;
    
since2k1 now.getFullYear();
    
_root.year since2k1;
    
_root.hours now.getHours();
    
dhours now.getHours()/24;
}

//Moon-Cycles
cycleindays 29.53058867;
cycleinhours 42524.0476848;

//performs calculations on date data for lunations and tidal readings
function calculate() {
    
aj 0;
    if (
n>=11) {
        
aj aj+30;
    }
    if (
n>=10) {
        
aj aj+31;
    }
    if (
n>=9) {
        
aj aj+30;
    }
    if (
n>=8) {
        
aj aj+31;
    }
    if (
n>=7) {
        
aj aj+30;
    }
    if (
n>=6) {
        
aj aj+30;
    }
    if (
n>=5) {
        
aj aj+31;
    }
    if (
n>=4) {
        
aj aj+30;
    }
    if (
n>=3) {
        
aj aj+31;
    }
    if (
n>=2) {
        
aj aj+28;
    }
    if (
n>=1) {
        
aj aj+31;
    }
    
aj aj+currdate;
    
since2k1 since2k1-2001;
    
leapfix 0;
    if (
since2k1>=4) {
        
leapfix since2k1/4;
    }
    
totaldays 0;
    
totaldays since2k1*365;
    
totaldays totaldays+leapfix;
    
totaldays totaldays+aj;
    
totaldays totaldays+dhours;

    
lunations = ((totaldays*850)+5130)/25101;
    
adjlunations Math.round(lunations*100);

    
adjlunations2 mbsubstring(adjlunations3, -1);
    
    
//Calculate the days until next full moon
    
if (adjlunations2>48 && adjlunations2<52) {
        
info "full moon";
    }
    if (
adjlunations2>98 || adjlunations2<2) {
        
info "new moon";
    }
    if (
adjlunations2<50) {
        
unitsleft adjlunations2;
        
        
daysleft = (unitsleft*cycleindays)/100;
        
daysclip daysleft%1;
        
dayslefttrunc daysleft-daysclip;
        
        
hoursleft = ((daysleft%1)*24);
        
hrsclip hoursleft%1;
        
hourslefttrunc hoursleft-hrsclip;
        
        
info "days left: "+dayslefttrunc+"D "+hourslefttrunc+"H";
    }
    if (
adjlunations2>50) {
        
unitsleft = ((100-adjlunations2)+50);
        
        
daysleft = (unitsleft*cycleindays)/100;
        
daysclip daysleft%1;
        
dayslefttrunc daysleft-daysclip;
        
        
hoursleft = ((daysleft%1)*24);
        
hrsclip hoursleft%1;
        
hourslefttrunc hoursleft-hrsclip;
        
        
info "days left: "+dayslefttrunc+"D "+hourslefttrunc+"H";
    }
}

// get todays info for first calculations
today();
calculate();

stop();

_root.moon_shadow_1.gotoAndStop(adjlunations2);
_root.moon_shadow_2.gotoAndStop(adjlunations2); 
Die Grafische Darstellung ist einwandfrei und stellt die Mondphasen in 100 Schritten dar. Da ich nun die restlichen Tage aus diesen 100 Schritten erechne ist das natürlich extrem ungenau, dementsprechend hinken die restlichen Tage meistens um einen hinterher...

Ich bin mir auch beim Script nicht so sicher ob die Methode ideal ist, denn da scheint man von 2001 an hochzuzählen...

Besser wäre ein verbrieftes Vollmond-Datum, von dem man hochrechnet (wie zB August 22 2002 22:29 UT)

Wenn jemand Lust hat das Script zu optimieren oder zu erweitern, oder die Phasen-Berechnung komplett umschmeißen will, wäre ich sehr dankbar! =)

Das fla ist anbei, auch wenn mein Codepfusch Schrott ist, die Animation der Schatten ist ganz brauchbar...

LG

sky
Angehängte Dateien
Dateityp: zip moon_phase.zip (22,5 KB, 12x aufgerufen)
skynet 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 23:25 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele