Netwars

Flash AS 2.0

[#1]
01.04.2006 17:17

Chociaz watpie w to, moze ktos bedzie wiedziec. Napisalem taki krotki kalendarz, podlaczony pod XML, w ktorym znajduja sie daty ktore zostana wyszczegolnione po wgraniu do SWF'a. Problem tkwi w tym, ze zaznacza mi tylko najwyzszy dzien w pojedynczym miesiacu.

XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<reservations>
<date day="1" month="1"></date>
<date day="2" month="1"></date>
<date day="10" month="1"></date>
</reservations>

AS:
xmlLoad = new XML();
xmlLoad.ignoreWhite = true;
xmlLoad.load("dates.xml");
xmlLoad.onLoad = xmlRun;
tMonth = new Array();
tMonth = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
tMonthDays = new Array();
tMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

var n:Number = tMonth.length;
build = function(n:Number):Array {
monthArray = new Array();
for (i = 0; i < n; i++) {
arrayName = tMonth[i];
arrayName = new Array();
monthArray[i] = arrayName;
for (j = 0; j < tMonthDays[i]; j++) {
monthArray[i][j] = j + 1;
}
}
return monthArray;
};
build(n);

function xmlRun(success) {
if (success) {
xmlRoot = this.firstChild;
xmlNodes = xmlRoot.childNodes;
tDayReserv = new Array();
tDayReserv[i][j] = xmlRoot.childNodes[i].attributes.day;
for (i = 0; i < xmlNodes.length; i++) {
m = xmlRoot.childNodes[i].attributes.month - 1;
d = xmlRoot.childNodes[i].attributes.day - 1;
tDayReserv[m] = new Array();
tDayReserv[m][d] = d + 1;
}
for (i = 0; i < tMonth.length; i++) {
_root["tM" + i].autoSize = true;
_root["tM" + i].multiline = true;
_root["tM" + i].wordWrap = true;
_root["tM" + i].selectable = false;
_root["tM" + i].html = true;
_root["tM" + i].htmlText = tMonth[i];
for (j = 0; j < tMonthDays[i]; j++) {
if (monthArray[i][j] == tDayReserv[i][j]) {
_root["tM" + i].htmlText += "<B><FONT COLOR='#CC0000'>" + monthArray[i][j] + "</FONT></I></B>";
j++;
}
_root["tM" + i].htmlText += monthArray[i][j];
}
}
//trace(tDayReserv[0][0] == monthArray[0][0]);
}
else {
trace("XML not loaded");
}
}

Scena:
12 dynamic textboxow o nazwach: tM[x] -> x:0-11.

Zrodlo i sam kalendarz:
http://www.wgtour.com/bohner/work/mikolajki/
=D

[#2]
01.04.2006 17:25

for (j = 0; j < tMonthDays[i]; j++) {
if (monthArray[i][j] == tDayReserv[i][j]) {
_root["tM" + i].htmlText += "<B><FONT COLOR='#CC0000'>" + monthArray[i][j] + "</FONT></I></B>";
j++;
}
_root["tM" + i].htmlText += monthArray[i][j];

dlaczego w tym fragmencie masz j++ w srodku petli ? cos tej logiki nie czaje ?

[#3]
01.04.2006 17:29

Bo inaczej zaznaczy mi np. 10.01 na czerwono a po tym napisze 10.01 wedlug petli. Wlasnie po to jest if(){};

[#4]
01.04.2006 17:51

or (j = 0; j < tMonthDays[i]; j++) {
if (monthArray[i][j] == tDayReserv[i][j]) {
_root["tM" + i].htmlText += "<B><FONT COLOR='#CC0000'>" + monthArray[i][j] + "</FONT></I></B>";
j++;
}
_root["tM" + i].htmlText += monthArray[i][j];
}

zamien na

or (j = 0; j < tMonthDays[i]; j++) {
if (monthArray[i][j] == tDayReserv[i][j]) {
_root["tM" + i].htmlText += "<B><FONT COLOR='#CC0000'>" + monthArray[i][j] + "</FONT></I></B>";
}
else{
_root["tM" + i].htmlText += monthArray[i][j];
}
}

[#5]
01.04.2006 18:50

Else tu nic nie zmieni, poniewaz nie jeszcze dwoch warunkow, jesli pierwszy (if) nie zostanie spelniony. Ale znalazlem blad, jest w przypisywaniu dni z XML'a do nowej tablicy.

Zaloguj się, żeby odpowiedzieć.