Foros del Web » Creando para Internet » Flash y Actionscript »

Problema con un calendario

Estas en el tema de Problema con un calendario en el foro de Flash y Actionscript en Foros del Web. buen dia chicos, me baje un calendario el cual carga la informacion desde un archivo XML este es el codigo del calendario: en el fotograma ...
  #1 (permalink)  
Antiguo 09/09/2009, 11:09
 
Fecha de Ingreso: marzo-2009
Ubicación: maracaibo
Mensajes: 41
Antigüedad: 15 años
Puntos: 0
Exclamación Problema con un calendario

buen dia chicos, me baje un calendario el cual carga la informacion desde un archivo XML

este es el codigo del calendario:

en el fotograma 1
Cita:
//XML file
//---------------------------------------------------
//LOCATION: assets/calendar.xml
//SOURCE:
//<calendar color="0x552233">
// <year value="2004">
// <month value="3">
// <day value="10">
// <image>this appears on the calendar day</image>
// <label>this appears on the calendar day</label>
// <description>this appears in the popup</description>
// </day>
// </month>
// </year>
//</calendar>
// day values must be in ascending order
// EX: <day value="3"></day>
// <day value="7"></day>
// <day value="10"></day>

//*test if days/months/years will work when not in ascending order


// initialize date
today_date = new Date();
todayMonth=today_date.getMonth() + 1
todayDay=today_date.getDate();
todayYear=today_date.getFullYear();

mymonth=todayMonth;
trace("month: " + mymonth);
myday=todayDay;
trace("day: " + myday);
myyear=todayYear;
trace("year: " + myyear);

//load xml file
calendar_xml = new XML();
calendar_xml.ignoreWhite=true;
calendar_xml.load("calendar.xml")
calendar_xml.onLoad = xml_handler;

var yearNode_xml;
var monthNode_xml;
var dayNode_xml;

// executes when xml file has loaded (used as MAIN function)
function xml_handler(success)
{
if (success==true){
trace ("...xml file loaded");
//set color
//_root.myColor="0x556677";
_root.myColorHTML="#"+calendar_xml.firstChild.attr ibutes.color;
_root.myColorAS="0x"+calendar_xml.firstChild.attri butes.color;
//find today's year
yearNode_xml=findYear(myyear);
//find today's month
monthNode_xml=findMonth(yearNode_xml,mymonth);

gotoAndPlay(2);
}

else{
trace("...error loading xml file");
break;
}
}

function findYear(year_num)
{
var yearNode_xml=calendar_xml.firstChild.firstChild;

while (yearNode_xml.attributes.value!=year_num)
{
yearNode_xml=yearNode_xml.nextSibling;
if (yearNode_xml == null)
{
trace ("...no xml enteries within that year");
return 0;// error flag
}
}

trace("yearXML: " + yearNode_xml.attributes.value);
return yearNode_xml;
}

function findMonth(yearNode_xml,month_num)
{
var monthNode_xml=yearNode_xml.firstChild;

while (monthNode_xml.attributes.value!=month_num)
{
monthNode_xml=monthNode_xml.nextSibling;
if (monthNode_xml == null)
{
trace ("...no xml enteries within that month");
return 0;// error flag
}
}

trace("monthXML: " + monthNode_xml.attributes.value);
return monthNode_xml;
}

function findDay(monthNode_xml,day_num)
{
var dayNode_xml=monthNode_xml.firstChild;

while (dayNode_xml.attributes.value!=day_num)
{
dayNode_xml=dayNode_xml.nextSibling;
if (dayNode_xml == null)
{
trace ("...no xml enteries for that day");
return 0;// error flag
}
}

trace("monthXML: " + monthNode_xml.attributes.value);
return dayNode_xml;
}

function setDay(dayNode_xml,day_num,mc){
trace("day: " + day_num);
trace("dayXML: " + dayNode_xml.attributes.value);



if (dayNode_xml.attributes.value==day_num){
//-----------------------------------------------
var itemsNode_xml=dayNode_xml.firstChild;

//initialize items array
itemsNodes_xml=[];
total = dayNode_xml.childNodes.length;
//empty text boxes and initialize content
_root[mc].description="";

//loop through the items array
for(i=0;i<total;i++){
itemsNodes_xml[i]=dayNode_xml.childNodes[i];
}
trace("yes entry for this day");

while (itemsNode_xml!=null){
//reference items in items array
for(p=0;p<total;p++){
if (itemsNodes_xml[p].nodeName=="label")
{
trace("yes label: " + itemsNode_xml.nodeValue);
_root[mc].label +=itemsNodes_xml[p].firstChild.nodeValue+"\n";

}
else if (itemsNodes_xml[p].nodeName=="image" && itemsNodes_xml[p].firstChild.nodeValue!=undefined)
{
trace("yes Image");
_root[mc].square_mc.pic.loadMovie(itemsNodes_xml[p].firstChild.nodeValue);
_root[mc].label +="\n\n";
}
else if (itemsNodes_xml[p].nodeName=="description")
{
trace("yes description: " + itemsNode_xml.nodeValue);
_root
_root[mc].description +=itemsNodes_xml[p].firstChild.nodeValue+"\n\n";
}
else{
trace("error");
}

itemsNode_xml=itemsNode_xml.nextSibling;
}
}


//-----------------------------------------
dayNode_xml=dayNode_xml.nextSibling;


if (dayNode_xml == null)
{
trace ("...no more xml day enteries");
return 0;// error flag
}

}

else{
trace("no entry for this day");
}

return dayNode_xml;
}

//*** testing functions ***
//-------------------------------------------------------------------
function printGroup (groupNode_xml){
trace ("<" + groupNode_xml.nodeName + " value=" + groupNode_xml.attributes.value1 + ">");
}

//-------------------------------------------------------------------
function printItem (itemNode_xml){
trace(" <" + itemNode_xml.nodeName + " URL=" + itemNode_xml.attributes.URL + ">");
trace(" -"+itemNode_xml.firstChild.nodeValue);
}

//-------------------------------------------------------------------
function printSubgroup(subgroupNode_xml){
trace(" <" + subgroupNode_xml.nodeName + " title=" + subgroupNode_xml.attributes.title+">");
}

function printSubitem(subitemNode_xml){
trace(" <" + subitemNode_xml.nodeName + " URL=" + subitemNode_xml.attributes.URL + ">");
trace(" -"+subitemNode_xml.firstChild.nodeValue);
}

stop();

en el fotograma 2

Cita:
// set up days in month
_root.today="Hoy: " + _root.todayMonth + " / " + _root.todayDay + " / " + _root.todayYear;
_root.dom_txt.textColor=_root.myColorAS2;
_root.lun_txt.textColor=_root.myColorAS;
_root.mar_txt.textColor=_root.myColorAS;
_root.mie_txt.textColor=_root.myColorAS;
_root.jue_txt.textColor=_root.myColorAS;
_root.vie_txt.textColor=_root.myColorAS;
_root.sab_txt.textColor=_root.myColorAS2;
_root.hoy_txt.textColor=_root.myColorAS;
back_btnColor=new Color(_root.btn_bkgrd_mc1);
back_btnColor.setRGB(_root.myColorAS);
forw_btnColor=new Color(_root.btn_bkgrd_mc2);
forw_btnColor.setRGB(_root.myColorAS);

month1 = 31;
month2 = 28;
month3 = 31;
month4 = 30;
month5 = 31;
month6 = 30;
month7 = 31;
month8 = 31;
month9 = 30;
month10 = 31;
month11 = 30;
month12 = 31;

// set up month names
namemonth1 = "Enero";
namemonth2 = "Febrero";
namemonth3 = "Marzo";
namemonth4 = "Abril";
namemonth5 = "Mayo";
namemonth6 = "Junio";
namemonth7 = "Julio";
namemonth8 = "Agosto";
namemonth9 = "Septiembre";
namemonth10 = "Octubre";
namemonth11 = "Noviembre";
namemonth12 = "Diciembre";

en el fotograma 3

Cita:
// which day of week does the month begin on
juliandate = Number(Number(Number(367*myyear-int(7*(Number(myyear)+Number(int((Number(mymonth)+ 9)/12)))/4))+Number(int((275*mymonth)/9)))+1)+1721013.5;
mjd = juliandate-2400000.5;
whichday = mjd-int(mjd/7)*7;
whichday = Number(whichday)+3;
if (Number(whichday)>=7) {
whichday = whichday-7;
}
// initialize day and row variables
counter = 2;
currentday = Number(whichday)+1;
currentrow = 0;
daysinmonth = eval("month" add mymonth);
// check for leap year
if (Number(int(myyear/4)) == Number((myyear/4)) and Number(mymonth) == 2) {
daysinmonth = 29;
}
//initialize day1
if(_root.yearNode_xml==0 || _root.monthNode_xml==0){
_root.dayNode_xml=0;
}

else{
_root.dayNode_xml=monthNode_xml.firstChild;
_root.dayNode_xml=setDay(_root.dayNode_xml,1,"squa re1");
}

//set day1 values


while (Number(counter)<=Number(daysinmonth)) {
// end of week? start new row
if (Number(currentday) == 7) {
currentday = 0;
currentrow = Number(currentrow)+1;
}
// duplicate square for each day in month and move to correct position and intialize values
duplicateMovieClip("/square1", "square" add counter, counter);
setProperty("/square" add counter, _x, Number(getProperty("/square1", _x))+Number(getProperty("/square1", _width)*currentday));
setProperty("/square" add counter, _y, Number(getProperty("/square1", _y))+Number(getProperty("/square1", _height)*currentrow));
set("/square" add counter add ":daynum", counter);

_root.dayNode_xml=setDay(_root.dayNode_xml,counter ,"square"+counter);

counter = Number(counter)+1;
currentday = Number(currentday)+1;
}
// move first day into right spot
setProperty("/square1", _x, Number(getProperty("/square1", _x))+Number(getProperty("/square1", _width)*whichday));


// highlight current day
if((_root.myyear==_root.todayYear)&&(_root.mymonth ==_root.todayMonth)){
var mc="square"+myday;
_root[mc].daynum_txt.textColor=_root.myColorAS;
}

// month title
monthtitle = eval("namemonth" add mymonth) add " " add myyear;
trace("MONTHTITLE: " + monthtitle);
_root.monthtitle_txt.text=monthtitle;
_root.monthtitle_txt.textColor=_root.myColorAS;

mientras que en el 4to y ultimo fotograma se encuentra un stop.... el calendario funciona de maravilla, pero necesito hacerle unas modificaciones al codigo para q los numeros correspondientes a los dias e los fines de semana me aparezcan en un color distinto; pero no consigo como; alguno podria explicarme? no se mucho de esto.
  #2 (permalink)  
Antiguo 09/09/2009, 17:28
Avatar de TMeister
Crazy Coder
 
Fecha de Ingreso: enero-2002
Ubicación: En la Oficina
Mensajes: 2.880
Antigüedad: 22 años, 3 meses
Puntos: 193
Respuesta: Problema con un calendario

Cambia esas lineas por el color que quieras.

Código actionscript:
Ver original
  1. _root.dom_txt.textColor=_root.myColorAS2;
  2. _root.sab_txt.textColor=_root.myColorAS2;
  #3 (permalink)  
Antiguo 10/09/2009, 09:59
 
Fecha de Ingreso: marzo-2009
Ubicación: maracaibo
Mensajes: 41
Antigüedad: 15 años
Puntos: 0
Respuesta: Problema con un calendario

hola y gracias por responder; hice lo que me dijiste, pero me cambio fue el color de los nombres de los dias mas no de los numeros... ya no se q hacer

Última edición por jakiras; 10/09/2009 a las 10:08
  #4 (permalink)  
Antiguo 21/09/2009, 08:36
 
Fecha de Ingreso: marzo-2009
Ubicación: maracaibo
Mensajes: 41
Antigüedad: 15 años
Puntos: 0
Respuesta: Problema con un calendario

hola chicos tengo otro problema con este mismo calendario; cuando uno hace click sobre las fechas se abre dentro de la peli un pequeño popup q carga desde el xml la informacion del evento programado, como haria para q me cargue una imagen desde ese mismo xml?

en esta web esta el calendario
ctl.mc.maricopa.edu/_resources/helpdocs/workshops/flash_components/FlashXMLCalendar.html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:48.