Codigo Falsh
Código AS:
Ver original
function addButtons() { var stuff2 = new Array(); var named2 = new Array(); var windows2 = new Array(); var id2 = new Array(); var idname = new Array(); var _loc4 = holder.buttons.length; for (i = 0; i < _loc4; i++) { btn = buttons.attachMovie("menu", "menu" + i, i); btn.name = i; buttons["menu" + i]._x = i * buttons["menu" + i]._width; buttons["menu" + i].name = i; btnsArray.push(btn); gs.TweenLite.to(buttons["menu" + i].parentButton.parentBG, 0, {tint: xml.firstChild.attributes.mainButtonColor}); btn.itemOverColor = holder.buttons[i].attributes.itemRollOverColor; btn.itemColor = holder.buttons[i].attributes.itemColor; btn.main = holder.main.attributes.subButtonColor; btn.parentButton.name = i; btn.parentButton.nameTXT.text = holder.buttons[i].attributes.title; btn.parentButton.nameTXT.textColor = btn.itemColor; btn.parentButton.onRollOver = function () { this.nameTXT.textColor = xml.firstChild.childNodes[this.name].attributes.itemRollOverColor; }; btn.parentButton.onRollOut = function () { this.nameTXT.textColor = btn.itemColor; }; btn.parentButton.onPress = function () { if (named2[this.name] == "link") { getURL(stuff2[this.name], windows2[this.name]); } // end if if (id2[this.name] == "id") { xml.send("xml/onlyinfo.php", xml, "POST"); } // end if if (named2[this.name] == "swf") { _root.pagesHolder.loadMovie(stuff2[this.name]); } // end if if (named2[this.name] == "goto") { _root.gotoAndPlay(stuff2[this.name]); } // end if }; if (holder.buttons[i].attributes.link != undefined) { named2.push("link"); stuff2.push(holder.buttons[i].attributes.link); windows2.push(holder.buttons[i].attributes.windows); } else if (holder.buttons[i].attributes.id != undefined) { idname.push("id"); id2.push(holder.buttons[i].attributes.id); } else if (holder.buttons[i].attributes.swf != undefined) { named2.push("swf"); stuff2.push(holder.buttons[i].attributes.swf); } else if (holder.buttons[i].attributes.goto != undefined) { named2.push("goto"); stuff2.push(holder.buttons[i].attributes.goto); } // end else if btn.menuItems = new Array(); btn.stuff = new Array(); btn.named = new Array(); btn.idn = new Array(); btn.idname = new Array(); btn.windows = new Array(); for (j = 0; j < holder.buttons[i].childNodes.length; j++) { btn.menuItems.push(holder.buttons[i].childNodes[j].attributes.title); if (holder.buttons[i].childNodes[j].attributes.link != undefined) { btn.named.push("link"); btn.stuff.push(holder.buttons[i].childNodes[j].attributes.link); btn.windows.push(holder.buttons[i].childNodes[j].attributes.windows); } // end if if (holder.buttons[i].childNodes[j].attributes.id != undefined) { btn.idn.push("id"); btn.idname.push(holder.buttons[i].childNodes[j].attributes.id); } // end if if (holder.buttons[i].childNodes[j].attributes.swf != undefined) { btn.named.push("swf"); btn.stuff.push(holder.buttons[i].childNodes[j].attributes.swf); } // end if if (holder.buttons[i].childNodes[j].attributes.goto != undefined) { btn.named.push("goto"); btn.stuff.push(holder.buttons[i].childNodes[j].attributes.goto); } // end if } // end of for } // end of for } // End of the function function xmlLoad() { spacingBeforeMenu = xml.firstChild.attributes.spacingBeforeMenu; gs.TweenLite.to(blackBG, 0, {tint: xml.firstChild.attributes.barsColor}); gs.TweenLite.to(btn.parentButton, 0, {tint: xml.firstChild.attributes.barsColor}); gs.TweenLite.to(btn.parentButton, 2, {tint: xml.firstChild.childNodes[0].attributes.bgColor}); gs.TweenLite.to(_root.mainBackground.mainBackgroundCover, 2, {tint: xml.firstChild.childNodes[0].attributes.bgColor}); logoHolder._x = 0; logoHolder._y = 0; logoHolder.logoBG.loadMovie(xml.firstChild.attributes.logo); _root.pagesHolder.loadMovie(xml.firstChild.attributes.initialPage); buttons._x = cover._x + spacingBeforeMenu; buttons._y = cover._y; holder.buttons = xml.firstChild.childNodes; holder.main = xml.firstChild; horSpacing = Number(xml.firstChild.attributes.horSpacing); addButtons(); verSpacing = Number(xml.firstChild.attributes.verSpacing); } // End of the function stop (); var xml = new XML(); xml.System.useCodepage = true; xml.ignoreWhite = true; xml.load("xml/menu.php"); xml.onLoad = xmlLoad; var spacingBeforeMenu; var holder = new MovieClip(); buttons._x = 450; buttons._y = 90; var btnsArray = new Array();
este es mi codigo PHP que realiza la converción a XML y me carga perfectamente el Menu
Código PHP:
<?php
function conectar()
{
//echo phpinfo();
require('../adminis-cms/conf/configuracion.php');
if (!($enlaze=mysql_connect("$sql_host", "$sql_usuario", "$sql_pass")))
{
echo "Error conectando a la base de datos.";
exit();
}
if (!mysql_select_db($sql_db,$enlaze))
{
echo "Error seleccionando la base de datos.";
exit();
}
return $enlaze;
}
$cone=conectar();
$sentencia = "SELECT * FROM menu ORDER BY menu.id ASC";
$pregunta=mysql_query($sentencia,$cone);
//$inv='formulario';
if (!$pregunta)
{
die('No hay datos:' . mysql_error());
}
else
{
$combo="<menu verSpacing='".(5)."' horSpacing='".(0)."' spacingBeforeMenu='".(0)."' textOver='".(0x00BBDD)."' subButtonColor='".(0x000000)."'>";
//$combo= $combo . "";
while ($res = mysql_fetch_row($pregunta))
{
$combo.= "<item title='". $res[1] ."' itemColor='".(0x000000)."' itemRollOverColor='".(0xFFCD00)."' bgColor='".(0x00BBDD)."'>";
$sqlsubmenu = "SELECT submenu.submenu, submenu.swf, submenu.id FROM submenu WHERE submenu.idmenu = '$res[0]'";
$consubmenu = mysql_query($sqlsubmenu,$cone);
while ($ressubmenu = mysql_fetch_row($consubmenu))
{
$combo .= "<subitem title='". $ressubmenu[0]."' swf='". $ressubmenu[1]."' id='". $ressubmenu[2]."' />";
}
$combo.="</item>";
}
$combo.="</menu>";
}
header("Content-type:application/xml enswf=utf-8");
echo utf8_decode($combo);
?>
este es el resultado de la converción del php al Xml
Código HTML:
<menu verSpacing="5" horSpacing="0" spacingBeforeMenu="0" textOver="48093" subButtonColor="0"> <item title="Home" itemColor="0" itemRollOverColor="16764160" bgColor="48093"/> <item title="Only Pet Shop" itemColor="0" itemRollOverColor="16764160" bgColor="48093"> <subitem title="Quienes Somos" swf="swf/onlyinfo.swf" id="1"/> <subitem title="Que Hacemos" swf="swf/onlyinfo.swf" id="2"/> </item> <item title="Servicios" itemColor="0" itemRollOverColor="16764160" bgColor="48093"> <subitem title="Consulta Veterinar�a" swf="" id="3"/> <subitem title="Perruquer�a" swf="" id="4"/> <subitem title="Clases para Cachorros" swf="" id="5"/> <subitem title="Venta de Mascotas" swf="" id="6"/> <subitem title="Adiestramiento" swf="" id="7"/> </item> <item title="Boutique" itemColor="0" itemRollOverColor="16764160" bgColor="48093"> <subitem title="Prendas" swf="" id="8"/> <subitem title="Juguetes" swf="" id="9"/> <subitem title="Accesorios" swf="" id="10"/> <subitem title="Alimentos" swf="" id="11"/> <subitem title="Golosinas" swf="" id="12"/> </item> <item title="Razas" itemColor="0" itemRollOverColor="16764160" bgColor="48093"> <subitem title="Perros" swf="" id="13"/> <subitem title="Gatos" swf="" id="14"/> </item> <item title="Contactenos" itemColor="0" itemRollOverColor="16764160" bgColor="48093"> <subitem title="Ubicaci�n" swf="" id="15"/> <subitem title="Comentarios" swf="" id="16"/> </item> </menu>
Código PHP:
<?php
require('../adminis-cms/conf/configuracion.php');
function conectar(){
//echo phpinfo();
require('../adminis-cms/conf/configuracion.php');
if (!($enlaze=mysql_connect("$sql_host", "$sql_usuario", "$sql_pass")))
{
echo "Error conectando a la base de datos.";
exit();
}
if (!mysql_select_db($sql_db,$enlaze))
{
echo "Error seleccionando la base de datos.";
exit();
}
return $enlaze;
}
$cone=conectar();
$sentencia = "SELECT * FROM cont WHERE cont.id = '".$_POST['idname']."'";
$pregunta=mysql_query($sentencia,$cone);
//$inv='formulario';
if (!$pregunta)
{
die('No hay datos:' . mysql_error());
}
else
{
$res = mysql_fetch_row($pregunta);
$foto = "imagenes/contenido/temp/".$res[4];
$combo.= "<cont><cont_text id='". $res[0] ."' foto='". $foto ."'>". $res[3] ."</cont_text></cont>";
}
header("Content-type:application/xml enswf=utf-8");
echo utf8_decode($combo);
?>
Hugo Aguilar