Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 14-08-2005, 20:08   #1 (permalink)
Neuer User
 
Registriert seit: Aug 2005
Beiträge: 3
Suche Hilfe (Actionscript für Kalender)

Ich suche für den Kalender (MX Standartkalender o.ä.) ein Actionscript, welches mir die Möglichkeit gibt über das entsprechend angeklickte Datum in einer xml Datei Daten abzurufen. Für Hilfe wäre ich sehr dankbar
firmaxy ist offline   Mit Zitat antworten
Alt 14-08-2005, 23:36   #2 (permalink)
flash4fun
 
Benutzerbild von cybermad
 
Registriert seit: Nov 2003
Ort: Bad Nauheim
Beiträge: 104
Hi,

habe vor kurzem im Web folgendes Beispiel gefunden.
Kann man relativ einfach verändern.
Ich hoffe das hilft dir weiter.

ActionScript:
  1. // begin date initialization
  2. now=new Date();
  3. today=now.getDate(); // get today's date
  4. month=now.getMonth(); // get the month
  5. year=now.getYear(); // get the year
  6. // use another Date object to find the lastdate
  7. lastdate=new Date(year, month+1, 0);
  8. lastday=lastdate.getDate(); // get the lastdate
  9. daycount=1; // variable to keep track of days
  10. weekcount=0; // variable to keep track of weeks
  11. // end date initialization
  12.  
  13. // loop through the month's days and create calendar
  14. while(daycount<=lastday){
  15.         now.setDate(daycount); // set the date object to current date
  16.         weekday=now.getDay(); // find the day of the week
  17.        
  18.         // create the date movie clip
  19.         _root.createEmptyMovieClip(daycount,daycount+10);
  20.         with(_root[daycount]){
  21.                 // create the date textfield with position based upon weekday and week counts
  22.                 createTextField('thisDate',daycount+100,weekday*20  ,weekcount*30,17,20);
  23.                 with(thisDate){
  24.                         selectable=false;
  25.                         if(_root.today==daycount){ // if the current day is today, change it's color
  26.                                 format=getTextFormat();
  27.                                 format.color=0xff0000;
  28.                                 setNewTextFormat(format);
  29.                         }
  30.                         text=daycount;
  31.                 }
  32.         }
  33.         if(weekday==6){weekcount++;} // increment the weekcount
  34.         _root.daycount++; // increment the daycount
  35. }
  36. // end day creation loop
  37.  

Gruß

cybermad
__________________
alles wird gut !
cybermad ist offline   Mit Zitat antworten
Alt 15-08-2005, 10:29   #3 (permalink)
Neuer User
 
Registriert seit: Aug 2005
Beiträge: 3
danke

Hallo, danke. Ich werde berichten wenn ich fertig bin.
gruß
firmaxy ist offline   Mit Zitat antworten
Alt 15-08-2005, 11:39   #4 (permalink)
Nordlicht
 
Benutzerbild von astaroth
 
Registriert seit: Jun 2001
Ort: Hamburg
Beiträge: 569
Probier mal das mit copy & paste

ActionScript:
  1. DateHolder = new Object();
  2. Date.prototype.getMonthDays = function(pJahr,pMonat) {
  3.     return (new Date(pJahr,pMonat+1,0).getDate());
  4. };
  5. Date.prototype.getDayName   = function(pTag) {
  6.     return ["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"][pTag]
  7. }
  8. Date.prototype.getMonthName = function(pMonat) {
  9.     return  ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"][pMonat]
  10. }
  11. DateHolder.datum       = new Date();
  12. DateHolder.jahr         = DateHolder.datum.getFullYear();
  13. DateHolder.monat       = DateHolder.datum.getMonth();
  14. DateHolder.aktTag     = DateHolder.datum.getDate();
  15. DateHolder.aktWochentag = DateHolder.datum.getDay();
  16. DateHolder.aktMonat     = DateHolder.datum.getMonth();
  17. DateHolder.aktJahr   = DateHolder.datum.getFullYear();
  18. DateHolder.ersterTag    = new Date(DateHolder.jahr,DateHolder.monat,0).getDay();
  19. DateHolder.tage         = DateHolder.datum.getMonthDays(DateHolder.jahr,DateHolder.monat);
  20. DateHolder.Kuerzel   = ["Mo","Di","Mi","Do","Fr","Sa","So"];
  21. DateHolder.aktMonatName = DateHolder.datum.getMonthName(DateHolder.aktMonat);
  22. DateHolder.aktTagName   = DateHolder.datum.getDayName(DateHolder.aktWochentag);
  23. DateHolder.datumtxt  = DateHolder.aktTagName + ", " + DateHolder.aktTag + "." + DateHolder.aktMonatName + " " + DateHolder.aktJahr
  24. MovieClip.prototype.makeTriangle = function (tposx,tposy){
  25.     this.moveTo(tposx,tposy);
  26.     this.beginFill(0xE0E0E0,100);
  27.     this.lineStyle(1,0x606060,100);
  28.     this.lineTo(tposx,tposy+10);
  29.     this.lineTo(tposx+15,tposy+5);
  30.     this.lineTo(tposx,tposy);
  31.     this.endFill();
  32.     this.moveTo(tposx+1,tposy-1);
  33.     this.lineStyle(1,0xFFFFFF,100);
  34.     this.lineTo(tposx+1,tposy+9);
  35.     this.lineTo(tposx+14,tposy+4);
  36.     this.lineTo(tposx+1,tposy-1);
  37. }
  38. MovieClip.prototype.makeTriangle2 = function (tposx,tposy){
  39.     this.moveTo(tposx+15,tposy);
  40.     this.beginFill(0xE0E0E0,100);
  41.     this.lineStyle(1,0x606060,100);
  42.     this.lineTo(tposx+15,tposy+10);
  43.     this.lineTo(tposx,tposy+5);
  44.     this.lineTo(tposx+15,tposy+1);
  45.     this.endFill();
  46.     this.moveTo(tposx+14,tposy+1);
  47.     this.lineStyle(1,0xFFFFFF,100);
  48.     this.lineTo(tposx+14,tposy+9);
  49.     this.lineTo(tposx,tposy+4);
  50.     this.lineTo(tposx+14,tposy);
  51. }
  52. MovieClip.prototype.makeCalendar = function (pPosX,pPosY,tiefe) {
  53.     var t = 0;
  54.     var spalten = 0;
  55.     var reihen = 0;
  56.     this.CalendarMC.removeMovieClip();
  57.     this.createEmptyMovieClip("CalendarMC",tiefe);
  58.     this.CalendarMC.createEmptyMovieClip("Backgr1",105);
  59.     this.CalendarMC.createEmptyMovieClip("Backgr2",106);
  60.     with (this.CalendarMC["Backgr1"]){
  61.         moveTo(0,0);
  62.         beginFill(0xD0D0D0,100);
  63.         lineStyle(1,0xFFFFFF,100);
  64.         lineTo(0,18);
  65.         lineStyle(2,0x808080,100);
  66.         lineTo(154,18);
  67.         lineTo(154,0);
  68.         lineStyle(1,0xFFFFFF,100);
  69.         lineTo(0,0);
  70.         endFill();
  71.     }
  72.     with (this.CalendarMC["Backgr2"]){
  73.         moveTo(0,0);
  74.         beginFill(0xD0D0D0,100);
  75.         lineStyle(1,0xFFFFFF,100);
  76.         lineTo(0,18);
  77.         lineStyle(2,0x808080,100);
  78.         lineTo(154,18);
  79.         lineTo(154,0);
  80.         lineStyle(1,0xFFFFFF,100);
  81.         lineTo(0,0);
  82.         endFill();
  83.     }
  84.     this.CalendarMC["Backgr1"]._x = pPosX-2;
  85.     this.CalendarMC["Backgr1"]._Y = pPosY+166;
  86.     this.CalendarMC["Backgr2"]._x = pPosX-2;
  87.     this.CalendarMC["Backgr2"]._Y = pPosY+196;
  88.     this.CalendarMC.createEmptyMovieClip("monButvor",110); //
  89.     with (this.CalendarMC["monButvor"]){//
  90.         makeTriangle(0,1);//
  91.     }
  92.     this.CalendarMC["monButvor"]._x = pPosX+135; //
  93.     this.CalendarMC["monButvor"]._y = pPosY+170;//
  94.     this.CalendarMC["monButvor"].onPress = function (){//
  95.         if (_root.DateHolder.monat<11){
  96.         _root.DateHolder.monat++;
  97.         setCal();
  98.         }
  99.     }
  100.     this.CalendarMC.createEmptyMovieClip("monButzur",111);
  101.     with (this.CalendarMC["monButzur"]){
  102.         makeTriangle2(0,0);
  103.     }
  104.     this.CalendarMC["monButzur"]._x = pPosX;
  105.     this.CalendarMC["monButzur"]._y = pPosY+170;
  106.     this.CalendarMC["monButzur"].onPress = function (){
  107.         if (_root.DateHolder.monat>0){
  108.         _root.DateHolder.monat--;
  109.         setCal();
  110.         }
  111.     }
  112.     this.CalendarMC.createTextField("MTF",120,pPosX+30,pPosY+165,100,20);
  113.     this.CalendarMC["MTF"].text = _root.DateHolder.datum.getMonthName(_root.DateHolder.monat);
  114.     this.CalendarMC["MTF"].selectable = false;
  115.     this.CalendarMC["MTF"].setTextFormat (_root.newFormTF2);   
  116.     this.CalendarMC.createEmptyMovieClip("jahrButvor",112);
  117.     with (this.CalendarMC["jahrButvor"]){
  118.         makeTriangle(0,1);
  119.     }
  120.     this.CalendarMC["jahrButvor"]._x = pPosX+135; //135
  121.     this.CalendarMC["jahrButvor"]._y = pPosY+200;
  122.     this.CalendarMC["jahrButvor"].onPress = function (){
  123.         _root.DateHolder.jahr++;
  124.         setCal();
  125.     }
  126.     this.CalendarMC.createEmptyMovieClip("jahrButzur",113);
  127.     with (this.CalendarMC["jahrButzur"]){
  128.         makeTriangle2(0,0);
  129.     }
  130.     this.CalendarMC["jahrButzur"]._x = pPosX;
  131.     this.CalendarMC["jahrButzur"]._y = pPosY+200;
  132.     this.CalendarMC["jahrButzur"].onPress = function (){
  133.         _root.DateHolder.jahr--;
  134.         setCal();
  135.     }
  136.     this.CalendarMC.createTextField("JTF",121,pPosX+30,pPosY+195,100,20);
  137.     this.CalendarMC["JTF"].text = _root.DateHolder.jahr;
  138.     this.CalendarMC["JTF"].selectable = false;
  139.     this.CalendarMC["JTF"].setTextFormat (_root.newFormTF2);       
  140.     this.CalendarMC.createEmptyMovieClip("Leiste",100)
  141.     with(this.CalendarMC["Leiste"]){
  142.         moveTo(0,0);
  143.         beginFill(0xD0D0D0,100);
  144.         lineStyle(1,0xFFFFFF,100);
  145.         lineTo(0,20);
  146.         lineStyle(1,0x808080,100);
  147.         lineTo(152,20);
  148.         lineTo(152,0);
  149.         lineStyle(1,0xFFFFFF,100);
  150.         lineTo(0,0);
  151.         endFill();
  152.     }
  153.     this.CalendarMC["Leiste"]._x =pPosX;
  154.     this.CalendarMC["Leiste"]._y =pPosY;
  155.     for (o=0;o<7;o++){
  156.         this.CalendarMC["Leiste"].createTextField("TF"+o,201+o,(o*22),0,23,20);
  157.         with(this.CalendarMC["Leiste"]["TF"+o]){
  158.             this.CalendarMC["Leiste"]["TF"+o].text = _root.DateHolder.Kuerzel[o];
  159.             this.CalendarMC["Leiste"]["TF"+o].selectable = false;
  160.             this.CalendarMC["Leiste"]["TF"+o].setTextFormat(_root.newFormTF2);
  161.         }
  162.     }
  163.     for (var i = 0; i < 40; i++) {
  164.         this.CalendarMC["Tag" + i].removeMovieClip();
  165.     }
  166.     for (var i = 0; i < _root.DateHolder.tage+_root.DateHolder.ersterTag; i++) {       
  167.         if (i >= _root.DateHolder.ersterTag) {
  168.             t++;
  169.             this.CalendarMC.createEmptyMovieClip("Tag" + i, i);
  170.             with(this.CalendarMC["Tag" + i]){
  171.                 moveTo (0, 0);
  172.                 beginFill(0xE0E0E0,100);
  173.                 lineStyle(1,0xFFFFFF,100);
  174.                 lineTo(0,20);
  175.                 lineStyle(1,0x808080,100);
  176.                 lineTo(20,20);
  177.                 lineTo(20,0);
  178.                 lineStyle(1,0xFFFFFF,100);
  179.                 lineTo(0,0);
  180.                 endFill();
  181.             }
  182.             this.CalendarMC["Tag" + i].createTextField("TF",i,1,2,20,20);
  183.             this.CalendarMC["Tag" + i]["TF"].text = t;
  184.             this.CalendarMC["Tag" + i]["TF"].setTextFormat(_root.newFormTF2);
  185.             this.CalendarMC["Tag" + i].dtag = t;
  186.             this.CalendarMC["Tag" + i].dmonat = _root.DateHolder.monat;
  187.             this.CalendarMC["Tag" + i].djahr = _root.DateHolder.jahr;
  188.             this.CalendarMC["Tag" + i].ddatum = t + ". " + _root.DateHolder.datum.getMonthName(_root.DateHolder.monat) + " " + _root.DateHolder.jahr;
  189.             this.CalendarMC["Tag" + i]._x = pPosX + spalten * this.CalendarMC["Tag" + i]._width;
  190.             this.CalendarMC["Tag" + i]._y = (pPosY+23) + reihen * this.CalendarMC["Tag" + i]._height;         
  191.             this.CalendarMC["Tag" + i].onRollOver = function() {
  192.                 this.clear();
  193.                 this.moveTo (0, 0);
  194.                 this.beginFill(0xC0C0C0,100);
  195.                 this.lineStyle(1,0x808080,100);
  196.                 this.lineTo(0,20);
  197.                 this.lineStyle(1,0xFFFFFF,100);
  198.                 this.lineTo(20,20);
  199.                 this.lineTo(20,0);
  200.                 this.lineStyle(1,0x808080,100);
  201.                 this.lineTo(0,0);
  202.                 this.endFill();
  203.             }
  204.             this.CalendarMC["Tag" + i].onRollOut = this.CalendarMC["Tag" + i].onReleaseOutside = function() {
  205.                 this.clear();
  206.                 this.moveTo (0, 0);
  207.                 this.beginFill(0xE0E0E0,100);
  208.                 this.lineStyle(1,0xFFFFFF,100);
  209.                 this.lineTo(0,20);
  210.                 this.lineStyle(1,0x808080,100);
  211.                 this.lineTo(20,20);
  212.                 this.lineTo(20,0);
  213.                 this.lineStyle(1,0xFFFFFF,100);
  214.                 this.lineTo(0,0);
  215.                 this.endFill();
  216.             }
  217.             this.CalendarMC["Tag" + i].onPress = function() {
  218.                 trace (this.ddatum);
  219.                 this.clear();
  220.                 this.moveTo (0, 0);
  221.                 this.beginFill(0xFFA0A0,100);
  222.                 this.lineStyle(1,0x808080,100);
  223.                 this.lineTo(0,20);
  224.                 this.lineStyle(1,0xFFFFFF,100);
  225.                 this.lineTo(20,20);
  226.                 this.lineTo(20,0);
  227.                 this.lineStyle(1,0x808080,100);
  228.                 this.lineTo(0,0);
  229.                 this.endFill();
  230.             }
  231.         }
  232.         if (t == _root.DateHolder.aktTag &&
  233.             _root.DateHolder.aktMonat ==
  234.             _root.DateHolder.monat &&
  235.             _root.DateHolder.aktJahr == _root.DateHolder.jahr) {
  236.             this.CalendarMC["Tag" + i].fillMeCal();
  237.             this.CalendarMC["Tag" + i].onRollOver = function (){};
  238.             this.CalendarMC["Tag" + i].onRollOut = function (){};
  239.         }
  240.         spalten++;
  241.         if (spalten == 7) {
  242.             spalten = 0;
  243.             reihen++;
  244.         }      
  245.     }   
  246. }
  247. MovieClip.prototype.fillMeCal = function (){
  248.     this.clear();
  249.     this.moveTo (0, 0);
  250.     this.beginFill(0xBEB0FF,100);
  251.     this.lineStyle(1,0xFFFFFF,100);
  252.     this.lineTo(0,20);
  253.     this.lineStyle(1,0x808080,100);
  254.     this.lineTo(20,20);
  255.     this.lineTo(20,0);
  256.     this.lineStyle(1,0xFFFFFF,100);
  257.     this.lineTo(0,0);
  258.     this.endFill();
  259. }
  260. setCal = function (){
  261.     _root.DateHolder.ersterTag = new Date(_root.DateHolder.jahr,_root.DateHolder.monat,0).getDay();
  262.     _root.DateHolder.tage =_root.DateHolder.datum.getMonthDays(_root.DateHolder.jahr,_root.DateHolder.monat);
  263.     makeCalendar(605,60,505);
  264. }
  265. setCal();

Änderungen dürften leicht zu machen sein.


....Gruß

Patrick
__________________
"Wir müssen die Rechte der Andersdenkenden selbst dann beachten, wenn sie Idioten oder schädlich sind. Wir müssen aufpassen."
Wachsamkeit ist der Preis der Freiheit - Keine Zensur!

– Wau Holland –

http://www.wauland.de
astaroth ist offline   Mit Zitat antworten
Alt 15-08-2005, 12:03   #5 (permalink)
tracer
 
Benutzerbild von andretti
 
Registriert seit: Jun 2004
Beiträge: 4.415
Thumbs up

wow!
wow!
wow!

wahnsinnsteil!
__________________
Viola per Sempre
Alle Angaben ohne Gewehr!
trace your open mind in variables !
andretti
ActionScript Dictionary
andretti 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 08:52 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele