8 Replies Latest reply on Dec 4, 2011 9:23 AM by armandix

    generate a drop down menu in action script 1

    armandix

      hello people ,

      I developed a menu and it loads a xml, now I'm trying to convert it to work with php and mysql.

      But I encountered a problem the flash will not load data that comes from mysql db.

       

      this is my menu AS code:

       

      gerar_menu = function(container, name, x, y, depth, node_xml){

                //declarar variaves

                var corrent_node;

                var corrent_item;

                var corrent_menu = container.createEmptyMovieClip(name, depth);

       

                for(var i=0; i< node_xml.childNodes.length; i++){

                          //um movie clip para cada item de menu

                          //attacheMovie(agrega o movieclip da livraria, novo nome dado pelo utilizador, ++ incremento);

                          corrent_item = corrent_menu.attachMovie("menuit","menu"+i+"_mc", i);

                          corrent_item._x = x + i*corrent_item._width;

                          corrent_item._y = y;

                          corrent_item.trackAsMenu = true;

                          // propriedades provenientes do XML

                          corrent_node = node_xml.childNodes[i];

                          corrent_item.action = corrent_node.attributes.action;

                          corrent_item.variables = corrent_node.attributes.variables;

                          corrent_item.name.text = corrent_node.attributes.name;

                          trace(corrent_node);

                          if (node_xml.childNodes[i].nodeName == "menu"){

                                    //abre o submenu

                                    corrent_item.node_xml = corrent_node;

                                    corrent_item.onRollOver = corrent_item.onDragOver  = function(){

                                    /*aqui meter as posições onde queres que as posicione*/

                                    var px = this._x;

                                    var py = this._y + this._height +2;

       

                                    // gerar submenu

                                    gerar_menu(corrent_menu, "submenu_mc", px, py, 1000, this.node_xml);

                                    var cor =new Color(this.background);

                                    cor.setRGB(0x767676);

       

                                    trace("enra");

                          };

                }else{

                          // caso não exista submenu esconde a seta

       

                          corrent_item.onRollOver = corrent_item.onDragOver  = function(){

                          corrent_menu.submenu_mc.removeMovieClip();

                          var cor =new Color(this.background);

                          cor.setRGB(0x767676);

                          };

       

                }

                //fim do else

       

                          corrent_item.onRollOut = corrent_item.onDragOut  = function(){

                          var cor =new Color(this.background);

                          cor.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});

                          }

       

                          corrent_item.submenu_mc.onRollOut = corrent_item.submenu_mc.onDragOut  = function(){

                          CloseSubmenus();

                          }

                          //qualquer menu em aberto ou a executar uma acção

                          corrent_item.onRelease = function(){

                          Actions[this.action](this.variables);

                          CloseSubmenus();

      };

       

      }//fim do loop;

       

       

      };

      // criar um menu com posição determinnada

      criar_menu = function(x, y, depth, menu_xml){

                gerar_menu(this, "mainmenu_mc", x, y, depth, menu_xml.firstChild);

      // fechar unicaexclusivamente os submenus caso estejam abertos

      // a inatncia mainmenu_mc continua

      mainmenu_mc.onMouseUp = function(){

                          if (mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root._xmouse, _root._ymouse, true)){

                                    CloseSubmenus();

                          }

                };

      };

       

       

      CloseSubmenus = function(){

                mainmenu_mc.submenu_mc.removeMovieClip();

      };

       

       

       

       

      //estas acções determinão metodos para estes objectos

      Actions = Object();

      Actions.gotoURL = function(urlVar){

      getURL(urlVar, "_blank");

      };

      Actions.message = function(msg){

      message_txt.text = msg;

      };

      Actions.newMenu = function(menuxml){

      menu_xml.load(menuxml);

      };

       

       

      //carrega o XML e , cria o MainMenu para o interpretar

      menu_xml = new XML();

      menu_xml.ignoreWhite = true;

      menu_xml.onLoad = function(ok){

                //caso o xml seja carregado com sucesso carrega o menu na posição

                if (ok){

                                              criar_menu(160, 50, 0, this);

                          message_txt.text = "message area";

                }else{

                          message_txt.text = "error:  XML not successfully loaded";

                }

      };

      // carrega primeiro o menu.xml em que lang determina a linguagem que ira carregar

       

       

      menu_xml.load("menu"+_root.lang+".php");

       

      And this is my php code:

       

      <?php

      $link =mysql_connect("localhost","brigansol","@brigansol@");

      mysql_select_db("brigansol");

       

       

      echo"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";

       

       

      $query="SELECT * FROM tbl_categorias ORDER BY categoria_pt ASC";

      $resultado = mysql_query($query);

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

       

      echo"<menu name='".$row['categoria_pt']."'>\n";

       

       

      $query1="SELECT tbl_categorias.id_categorias, tbl_categorias.categoria_pt, tbl_subcategorias.id_subcategorias, tbl_subcategorias.categorias_id, tbl_subcategorias.subcategoria_pt, tbl_subcategorias.referencia FROM tbl_categorias JOIN tbl_subcategorias WHERE tbl_categorias.id_categorias = tbl_subcategorias.categorias_id AND tbl_subcategorias.categorias_id =".$row['id_categorias']." ORDER BY tbl_subcategorias.subcategoria_pt ASC";

      $resultado1 = mysql_query($query1);

      while($row1 = mysql_fetch_array($resultado1)) {

       

      echo"<item name='".$row1['subcategoria_pt']."' action='' variables=''></item>\n";

       

       

      }

       

       

      echo"</menu>\n";

      }

      mysql_close($link);

      ?>

       

       

       

       

       

       

       

       


       


        • 1. Re: generate a drop down menu in action script 1
          kglad Adobe Community Professional & MVP

          are you really publishing for as1?  if yes, is this a mobile app that needs to use flashlite?

           

          for what flash player version are you publishing?

          • 2. Re: generate a drop down menu in action script 1
            armandix Level 1

            flash 9 action script 1.No is a menu for a website.

            • 3. Re: generate a drop down menu in action script 1
              kglad Adobe Community Professional & MVP

              why aren't you publishing for as2, then?  you should change your publish settings and retest.

              • 4. Re: generate a drop down menu in action script 1
                armandix Level 1

                I've tried everything , but does not work. I am creating an app that works locally as a catalog

                • 5. Re: generate a drop down menu in action script 1
                  kglad Adobe Community Professional & MVP

                  using as2 publish settings, what's the first problem?

                  • 6. Re: generate a drop down menu in action script 1
                    armandix Level 1

                    Let me explain my project...

                    I am creating a catalog, and I need to create a menu that load dynamically with data from the db.

                    My biggest problem is:

                    To load data from db using php to create xml file dynamically, but the flash does not readbeyond the tag for "<?Php ?>"

                    I'll post some screenshots of my work.

                     

                    without php:

                    xml.jpg

                    with php:


                    php.jpg



                    • 7. Re: generate a drop down menu in action script 1
                      kglad Adobe Community Professional & MVP

                      use the onData method instead of the onLoad and view the return from your php to see if you have an error begin returned.

                      • 8. Re: generate a drop down menu in action script 1
                        armandix Level 1

                        Kglad , tanks for your help!

                        I ready solved the problem. But a new problem appeared.

                        between this code lines:

                         

                        var corrent_menu = container.createEmptyMovieClip(name, depth);

                         

                                  for(var i=0; i< node_xml.childNodes.length; i++){

                                            //um movie clip para cada item de menu

                                            //attacheMovie(agrega o movieclip da livraria, novo nome dado pelo utilizador, ++ incremento);

                                            corrent_item = corrent_menu.attachMovie("menuit","menu"+i+"_mc", i);

                                            corrent_item._x = x + i*corrent_item._width;

                                            corrent_item._y = y;

                                            corrent_item.trackAsMenu = true;

                                            // propriedades provenientes do XML

                                            corrent_node = node_xml.childNodes[i];

                                            corrent_item.action = corrent_node.attributes.action;

                                            corrent_item.variables = corrent_node.attributes.variables;

                                            corrent_item.name.text = corrent_node.attributes.name;

                                            trace(corrent_node);

                                            if (node_xml.childNodes[i].nodeName == "menu"){

                                                      //abre o submenu

                                                      corrent_item.node_xml = corrent_node;

                                                      corrent_item.onRollOver = corrent_item.onDragOver  = function(){

                                                      /*aqui meter as posições onde queres que as posicione*/

                                                      var px = this._x;

                                                      var py = this._y + this._height +2;

                         

                                                      // gerar submenu

                                                      gerar_menu(corrent_menu, "submenu_mc", px, py, 1000, this.node_xml);

                                                      var cor =new Color(this.background);

                                                      cor.setRGB(0x767676);

                         

                                                      trace("enra");

                                            };

                        .

                        I need correct a problem and make every parent node shows the childrens nodes...

                        with these changes is to repeat several times the main menu

                        I'll post some screenshots Flash project :

                         

                        flash.jpg


                        xml :


                        xml.jpg