Hola a todos, interesante tema necesito que me ayuden; descargue un calendario el cual emplea estos codigos que adjunto; he conseguido modificar la interfaz original y le di un aspecto mas personal; pero mi problema viene dado porque quiero cargar una imagen desde el archivo xml (q tambn trae) en un popup que es llamado desde la biblioteca por un boton al ser presionado, este popup me muestra informacion textual q uno le coloca en el archivo xml; pero quiero una forma de insertar tambien en ese popup una imagen desde ese mismo archivo. yo coloque dentro del popup un movieclip vacio con el nombre pic el cual queria reemplazar por la imagen pero por mas que intento no lo consigo; si pueden ayudarme se los agradeceria mucho.
Este codigo se encuentra en un fotograma del popup
Código ActionScript :
_root.forwd_btn.enabled=false;
_root.back_btn.enabled=false;
mydate_txt.textColor=_root.myColorAS;
//CSS
trace(_root.myColor);
var styles = new TextField.StyleSheet();
styles.setStyle("a:link",
{color: _root.myColorHTML,textDecoration: 'underline'}
);
styles.setStyle("a:hover",
{color: _root.myColorHTML,textDecoration: 'none'}
);
popup_txt.styleSheet = styles;
stop();
for (var i=1;i<=31;i++){
var mc="square" + i;
_root[mc].square_mc.square_btn.enabled=false;
}Este codigo es el que se encuentra en el boton
[as]on (release) {
var month_path="namemonth" + _root.mymonth;
_root.print_btn.enabled=false;
_root.attachMovie("popup","popup1",100);
_root.popup1._x=2.5;
_root.popup1._y=2.5;
_root.popup1.mydate=this._parent.daynum+" "+ _root[month_path] + ", " + _root.myyear;
if(this._parent.description==undefined){
_root.popup1.description="";
}else{
_root.popup1.description=this._parent.description;//description stored in corresponding square (day)
}
}
[as]
Estos son los codigos de la animacion.
Fotograma 1
[as]//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.attributes.color;
_root.myColorAS="0x"+calendar_xml.firstChild.attributes.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();[/as]
Fotograma 2
[as]// set up days in month
_root.today="Hoy: " + _root.todayDay + " / " + _root.todayMonth + " / " + _root.todayYear;
_root.dom_txt.textColor=_root.myColorAS;
_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.myColorAS;
_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";[/as]
Fotograma 3
[as]// 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,"square1");
}
//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=0x0066ff;
}
// month title
monthtitle = eval("namemonth" add mymonth) add " " add myyear;
trace("MONTHTITLE: " + monthtitle);
_root.monthtitle_txt.text=monthtitle;
_root.monthtitle_txt.textColor=_root.myColorAS;
[/as]
Fotograma 4 tiene solo un [as]stop();[/as]
Por favor muchachos, no posteo con frecuencia o me atreveria a decir que nunca lo he hecho, pero 100pre ando revisando los tutos de aca que son muy buenos y esta vez necesito urgentemente su ayuda.... gracias