Skip to main content
Known Participant
September 25, 2011
Answered

my flash reads the xml, but does not understand the tag php....

  • September 25, 2011
  • 1 reply
  • 3642 views

my flash reads the xml, but does not understand the tag php. I want to read my xml dynamically, please help me.

code:

stop();

function randomOrder(targetArray)

{

    var _loc2 = targetArray.length;

    var _loc3 = [];

    for (var _loc1 = 0; _loc1 < _loc2; ++_loc1)

    {

        _loc3[_loc1] = _loc1;

    } // end of for

    var _loc4 = [];

    for (var _loc1 = 0; _loc1 < _loc2; ++_loc1)

    {

        _loc4[_loc1] = _loc3.splice(Math.floor(Math.random() * _loc3.length), 1);

    } // end of for

    var _loc5 = [];

    for (var _loc1 = 0; _loc1 < _loc2; ++_loc1)

    {

        _loc5[_loc1] = targetArray[_loc4[_loc1]];

    } // end of for

    return (_loc5);

} // End of the function

var randomNUM = "?n=" + random(9999);

_root.lan = 1;

var homehead;

var homelink;

var homelinkwindow;

var homebg;

var homeflash;

var lamp = Array();

var promo = Array();

var promobottom = Array();

var headimg = Array();

f_xmlwork2 = new XML();

f_xmlwork2.ignoreWhite=true;

f_xmlwork2.load("banner.php");

f_xmlwork2.onLoad = function(sucess){

    if (sucess){

         trace ("XML loaded!");

         f_xmlItemx2 = parseInt(this.firstChild.childNodes[0].firstChild);

         f_totalx2 = f_xmlItemx2.length;

        trace(f_totalx2);

         var _loc12 =0;

         // declarar a imagem de fundo

         homebg = this.firstChild.childNodes[0].firstChild.nodeValue;

         f_headimg = this.childNodes[1];

        

             for (var _loc2 = 0; _loc2 < f_headimg.childNodes.length; ++_loc2)    {

juju = f_headimg.childNodes[_loc2];

jj = headimg.push({headimg: f_headimg.childNodes[_loc2].attributes.headimg, bgimg: f_headimg.childNodes[_loc2].attributes.bgimg, msgimg: f_headimg.childNodes[_loc2].attributes.msgimg, leftthrow: f_headimg.childNodes[_loc2].attributes.leftthrow, rightthrow: f_headimg.childNodes[_loc2].attributes.rightthrow});

             }

             //end for

            

allpromo = this.childNodes[2];

jjpromo = allpromo.childNodes;

for (var _loc2 = 0; _loc2 < allpromo.childNodes.length; ++_loc2)

    {

trace (jjpromo[_loc2].attributes.title);

jj = promo.push({img: jjpromo[_loc2].attributes.img, title: jjpromo[_loc2].attributes.title, url: jjpromo[_loc2].attributes.url, window: jjpromo[_loc2].attributes.window, info: jjpromo[_loc2].childNodes[0].nodeValue});

    }

    // end of for

    allpromobottom = this.childNodes[3];

    jjpromobottom = allpromobottom.childNodes;

    for (var _loc2 = 0; _loc2 < allpromobottom.childNodes.length; ++_loc2)

    {

        trace (jjpromo[_loc2].attributes.title);

        jj = promobottom.push({url: jjpromobottom[_loc2].attributes.url, window: jjpromobottom[_loc2].attributes.window, info: jjpromobottom[_loc2].childNodes[0].nodeValue});

    } // end of for

     if (f_xmlwork2.loaded == true)

    {

        headimg = randomOrder(headimg);

        for (var _loc2 = 0; _loc2 < f_headimg.childNodes.length; ++_loc2)

        {

            trace (headimg[_loc2].headimg);

        } // end of for

        play ();

    } // end if

    }

}

trace(f_xmlwork2);

stop();

PHP code:

<?

$link=  mysql_connect("localhost","rnpac_eco","123");

mysql_select_db("rnpac");

$dir="banner/";

$dir1="produtos/img_pro/";

$dir2="universo/actividades/";

$sql = 'SELECT tbl_produto.id_produto, tbl_produto.produto, tbl_produto.legenda, tbl_produto.detalhe, tbl_produto.preco, tbl_produto.produto_cat_id, tbl_detalhe_produto.proprietario, tbl_detalhe_produto.local, tbl_detalhe_produto.qualidade, tbl_detalhe_produto.alcool, tbl_detalhe_produto.acidez, tbl_detalhe_produto.ph, tbl_detalhe_produto.informacao, tbl_detalhe_produto.gestor, tbl_detalhe_produto.condicionamento, tbl_detalhe_produto.detalhe_t, tbl_detalhe_produto.interesse, tbl_detalhe_produto.transporte, tbl_detalhe_produto.produto_id, tbl_imagem_produto.id_imagem, tbl_imagem_produto.imagem1, tbl_imagem_produto.imagem2, tbl_imagem_produto.imagem3, tbl_imagem_produto.imagem4, tbl_imagem_produto.imagem5, tbl_imagem_produto.imagem6

FROM tbl_cat_produto, tbl_produto, tbl_detalhe_produto, tbl_imagem_produto WHERE tbl_produto.id_produto = tbl_detalhe_produto.produto_id AND tbl_produto.id_produto = tbl_imagem_produto.produto_id ORDER BY RAND()';

$resultado = mysql_query($sql)

or die ("Não foi possível realizar a consulta.");

$row1=mysql_fetch_array($resultado);

$sql = "SELECT  tbl_sub_universo.id_subuniverso, tbl_sub_universo.subuniverso, tbl_sub_universo.universo_id, tbl_actividade.id_actividade, tbl_actividade.entidade, tbl_actividade.legenda, tbl_actividade.subuniverso_id, tbl_actividade.det, tbl_actividade.preco, tbl_actividade.data, tbl_detalhe_actividade.actividade_id, tbl_detalhe_actividade.periodo, tbl_detalhe_actividade.descricao, tbl_detalhe_actividade.programa, tbl_detalhe_actividade.informacoes, tbl_detalhe_actividade.actividades, tbl_detalhe_actividade.localizacao, tbl_detalhe_actividade.locais, tbl_detalhe_actividade.servicos, tbl_imagem_produto.id_imagem, tbl_imagem_produto.imagem1,tbl_imagem_produto.imagem2, tbl_imagem_produto.imagem3, tbl_imagem_produto.imagem4, tbl_imagem_produto.imagem5, tbl_imagem_produto.imagem6, tbl_imagem_produto.actividade_id FROM  tbl_sub_universo, tbl_actividade, tbl_detalhe_actividade, tbl_imagem_produto WHERE tbl_actividade.id_actividade =tbl_imagem_produto.actividade_id AND tbl_actividade.id_actividade =tbl_detalhe_actividade.actividade_id ORDER BY RAND()";

$resultado = mysql_query($sql)

or die ("Não foi possível realizar a consulta.");

$row2=mysql_fetch_array($resultado);

$query='SELECT * FROM tbl_banner ORDER BY RAND()';

$resultado = mysql_query($query);

echo' <?xml version=\"1.0\"?>

<home_left_headline>

<bgimg>'.$dir2.''.$row1['imagem1'].'</bgimg>

</home_left_headline>

<home_flash>';

while($row = mysql_fetch_array($resultado)) {

       

echo'<swf headimg="" bgimg="" msgimg="" leftthrow="" rightthrow=""></swf>';

}

echo'</home_flash>';

echo'<promotop>

<promo img="" title="" url="" ><![CDATA[]]></promo>

<promo img="" title="" url="" ><![CDATA[]]></promo>

</promotop>';

mysql_close($link);

This topic has been closed for replies.
Correct answer kglad

I have php installed  in my computer  a virtual server


you wouldn't be seeing that php trace if your php were setup correctly.  upload your files and retest.

1 reply

Ned Murphy
Legend
September 25, 2011

What/where is the php tag you are talking about?

armandixAuthor
Known Participant
September 25, 2011

Ned the problem is  the action script code work if I remove the php tag "<? ?>" and all php code. But with the php tag accesses the file and does not read.

Ned Murphy
Legend
September 26, 2011

Ned I tried everything , my server support php, i don't understand what's is the problem.

I need charge the information dynamically, because I don't have time for editing a xml file each time I need.

In the file when I open the tag PHP the actionscript stop reading .


You should not be getting a php tag.  It should only be getting what the file echo's... the xml formatted data