Ir para conteúdo
Fórum CódigoFonte.net
Leonardo Goulart

Problema com sistema de busca

Recommended Posts

e ae gurizada! buenas?? ;)

bom, tenho um problemão nas mãos e preciso da ajuda de voces.

Vou tentar explicar o que acontece. Tenho um catalogo eletronico onde é possivel fazer a busca de produtos... até aí tudo tranquilo, porém os resultados da pesquisa ficam todos com o mesmo link, por exemplo:

digito na busca "fogão", são encontrados 3 produtos diferentes, e os 3 caem no mesmo link....

O pior é que tenho que entregar isso hoje.... Chocado Chorar

Se alguem puder me dar uma luz ae eu fico eternamente grato....

ta ae o codigo q usei no sistema de busca...

import mx.transitions.Tween;
import mx.transitions.easing.*;

pesqExit.onRelease = function(){
   var pesqPTweenS:Tween = new Tween(_root.pesquisaBox, "_y", Back.easeIn, _root.pesquisaBox._y, -280, 1, true);
}

var content_XML:XML = new XML();
pegaFoto =  new Array();

photo_filenameS = new Array();
photo_thumbnailS = new Array();
photo_descriptionS = new Array();
photo_filename02S = new Array();
photo_thumbnail02S = new Array();
photo_nome02S = new Array();
photo_desc02S = new Array();
photo_filename03S = new Array();
photo_thumbnail03S = new Array();
photo_nome03S = new Array();
photo_desc03S = new Array();
photo_filename04S = new Array();
photo_thumbnail04S = new Array();
photo_nome04S = new Array();
photo_desc04S = new Array();
photo_estofadoS = new Array();

var arrList:Array = new Array();
var testeI:Array = new Array();

content_XML.ignoreWhite = true;
menu_item_group.menu_item._visible = false;
content_XML.onLoad = function(success){
   if (success){
      _root.inputSearch._visible = true;
   }else{
      resultsTxt.text = "Error loading XML";
   }
}
_root.inputSearch._visible = false;
content_XML.load("photos/produtos.xml");

myListener = new Object();
myListener.onKeyUp = function(){
   if(Key.getCode() == Key.ENTER){
      _root.btnSearch.onRelease();
   }
}
Key.addListener(myListener);

_root.btnSearch.onRelease = function(){
   cb_categorias.removeAll();
   var PesquisaTween:Tween = new Tween(_root.pesquisaBox, "_y", Back.easeOut, _root.pesquisaBox._y, 200, 1.5, true);
   entry = "";
   //cb_categorias.removeAll();
   arrList = [];

   if(_root.inputSearch.text.length < 3){
      resultsTxt.text = "Favor redefinir o termo da pesquisa!";
      Selection.setFocus("_root.inputSearch");
      Selection.setSelection(0,_root.inputSearch.text.length);
      return(0);
      cb_categorias.removeAll();
      arrList = [];
      //var arrList:Array = new Array();
   }   
   checker = 0;
   for(i=0;i<content_XML.firstChild.childNodes.length;i++){
      searchStringTitle = String(content_XML.firstChild.childNodes.childNodes[0].firstChild).toLowerCase()
;
      searchStringContent = String(content_XML.firstChild.childNodes.attributes.estofado).toLowerCase();
      //trace(searchStringContent);
      if(searchStringContent.indexOf(_root.inputSearch.text.toLowerCase()) != -1 || searchStringTitle.indexOf(_root.inputSearch.text.toLowerCase()) != -1){      
         checker =1;

      pegaFoto = content_XML.firstChild.childNodes.attributes.filename;
      photo_filenameS = content_XML.firstChild.childNodes.attributes.filename;
      photo_filename02S = content_XML.firstChild.childNodes.attributes.filename02;
      photo_thumbnail02S = content_XML.firstChild.childNodes.attributes.thumbnail02;
      photo_nome02S = content_XML.firstChild.childNodes.attributes.nome02;
      photo_desc02S = content_XML.firstChild.childNodes.attributes.desc02;
      photo_filename03S = content_XML.firstChild.childNodes.attributes.filename03;
      photo_thumbnail03S = content_XML.firstChild.childNodes.attributes.thumbnail03;
      photo_nome03S = content_XML.firstChild.childNodes.attributes.nome03;
      photo_desc03S = content_XML.firstChild.childNodes.attributes.desc03;
      photo_filename04S = content_XML.firstChild.childNodes.attributes.filename04;
      photo_thumbnail04S = content_XML.firstChild.childNodes.attributes.thumbnail04;
      photo_nome04S = content_XML.firstChild.childNodes.attributes.nome04;
      photo_desc04S = content_XML.firstChild.childNodes.attributes.desc04;
      photo_estofadoS = content_XML.firstChild.childNodes.attributes.estofado;
      arrList.push(content_XML.firstChild.childNodes.attributes.estofado);
      testeI = i;
      trace(arrList);
      trace(testeI);
      cb_categorias.dataProvider = arrList;
      //cb_categorias.label = arrList;
      //cb_categorias.addItem ({label:arrList, data:testeI});
      //cb_categorias.addItem({label:arrList,data:i});
        // cb_categorias.addItem({label:arrList, data:testeI});



      var ListListener:Object = new Object ();
      ListListener.change = function (evt_obj:Object)
      {
      // Display each property of the object.
/*      var valores:String = evt_obj.target.selectedItem;

      //for (var i:String in evt_obj.target.selectedItem) {;

      trace(cb_categorias.selectedItem.data);
       //cb_categorias.removeAll();
      //}
      //trace (valores);*/

      var pesqPTweenS2:Tween = new Tween(_root.pesquisaBox, "_y", Back.easeIn, _root.pesquisaBox._y, -280, 1, true);
      var item_no = testeI;
      trace(item_no);
      _root.pic.loadMovie("photos/" + photo_filenameS[item_no]);
         _root.thumbnail02.loadMovie("photos/" + photo_thumbnail02S[item_no]);
         _root.thumbnail03.loadMovie("photos/" + photo_thumbnail03S[item_no]);
         _root.thumbnail04.loadMovie("photos/" + photo_thumbnail04S[item_no]);

         _global.posicao = (item_no);



         _root.estofado.text = photo_estofadoS[item_no];
         _root.nome02.nome02.text = photo_nome02S[item_no];
         _root.nome03.nome03.text = photo_nome03S[item_no];
         _root.nome04.nome04.text = photo_nome04S[item_no];


         _root.hit02.enabled = false;
         _root.hit03.enabled = false;
         _root.hit04.enabled = false;
         _root.nome02._visible = false;
         _root.nome03._visible = false;
         _root.nome04._visible = false;




         if (photo_thumbnail02S[item_no] != ""){

         _root.hit02.enabled = true;
         _root.hit02.onRelease = function(){
            _root.pic.loadMovie("photos/" + photo_filename02S[item_no]);
            }

         if (photo_desc02S[item_no] != ""){
            _root.nome02._visible = true;
         _root.nome02.onRelease = function(){

         var infoP2Tween:Tween = new Tween(_root.infoP, "_y", Back.easeOut, _root.infoP._y, 30, 1.5, true);
         //trace(posicao);
         _root.infoP.carregaImagem.loadMovie("photos/" + photo_desc02S[posicao]);
         _root.infoP.desc.text = photo_desc02S[item_no];
         _root.infoP.tit.text = photo_nome02S[item_no];
         }
                                       }
         }

         if (photo_thumbnail03S[item_no] != ""){

         _root.hit03.enabled = true;

         _root.hit03.onRelease = function(){
            _root.pic.loadMovie("photos/" + photo_filename03S[item_no]);
         }
         if (photo_desc03S[item_no] != ""){
         _root.nome03._visible = true;
         _root.nome03.onRelease = function(){
         var infoP3Tween:Tween = new Tween(_root.infoP, "_y", Back.easeOut, _root.infoP._y, 30, 1.5, true);
         _root.infoP.carregaImagem.loadMovie("photos/" + photo_desc03S[posicao]);
         _root.infoP.desc.text = photo_desc03S[item_no];
         _root.infoP.tit.text = photo_nome03S[item_no];
         }
                                       }
         }

         if (photo_thumbnail04S[item_no] != ""){
         _root.hit04.enabled = true;

         _root.hit04.onRelease = function(){
            _root.pic.loadMovie("photos/" + photo_filename04S[item_no]);
         }
         if (photo_desc04S[item_no] != ""){
            _root.nome04._visible = true;
         _root.nome04.onRelease = function(){
         var infoP4Tween:Tween = new Tween(_root.infoP, "_y", Back.easeOut, _root.infoP._y, 30, 1.5, true);
         _root.infoP.carregaImagem.loadMovie("photos/" + photo_desc04S[posicao]);
         _root.infoP.desc.text = photo_desc04S[item_no];
         _root.infoP.tit.text = photo_nome04S[item_no];
         }
         }

         }




      };
      // Add listener.
      cb_categorias.addEventListener ("change",ListListener);


      menu_item_group.menu_item.duplicateMovieClip("menu_item" + i, i);
      menu_item_group["menu_item" + i].over = true;
      menu_item_group["menu_item" + i].item_label = content_XML.firstChild.childNodes.attributes.estofado;
      menu_item_group["menu_item" + i].item_no = i;
      menu_item_group["menu_item" + i]._y = i * 20;
      menu_item_group["menu_item" + i].flashmo_button._visible = true;
      menu_item_group["menu_item" + i].over = true;
      menu_item_group["menu_item" + i].flashmo_button.onRollOver = function()
      {
         this._parent.over = false;
      };
      menu_item_group["menu_item" + i].flashmo_button.onRollOut =
      menu_item_group["menu_item" + i].flashmo_button.onDragOut = function ()
      {
         this._parent.over = true;
      };
      menu_item_group["menu_item" + i].flashmo_button.onRelease = function()
      {
         _root.pic.loadMovie("photos/" + photo_filenameS[this._parent.item_no]);
         _root.thumbnail02.loadMovie("photos/" + photo_thumbnail02S[this._parent.item_no]);
         _root.thumbnail03.loadMovie("photos/" + photo_thumbnail03S[this._parent.item_no]);
         _root.thumbnail04.loadMovie("photos/" + photo_thumbnail04S[this._parent.item_no]);

         _global.posicao = (this._parent.item_no);



         _root.estofado.text = photo_estofadoS[this._parent.item_no];
         _root.nome02.nome02.text = photo_nome02S[this._parent.item_no];
         _root.nome03.nome03.text = photo_nome03S[this._parent.item_no];
         _root.nome04.nome04.text = photo_nome04S[this._parent.item_no];


         _root.hit02.enabled = false;
         _root.hit03.enabled = false;
         _root.hit04.enabled = false;
         _root.nome02._visible = false;
         _root.nome03._visible = false;
         _root.nome04._visible = false;




         if (photo_thumbnail02S[this._parent.item_no] != ""){

         _root.hit02.enabled = true;
         _root.hit02.onRelease = function(){
            _root.pic.loadMovie("photos/" + photo_filename02S[this._parent.item_no]);
            }

         if (photo_desc02S[this._parent.item_no] != ""){
            _root.nome02._visible = true;
         _root.nome02.onRelease = function(){

         var infoP2Tween:Tween = new Tween(_root.infoP, "_y", Back.easeOut, _root.infoP._y, 30, 1.5, true);
         //trace(posicao);
         _root.infoP.carregaImagem.loadMovie("photos/" + photo_desc02S[posicao]);
         _root.infoP.desc.text = photo_desc02S[this._parent.item_no];
         _root.infoP.tit.text = photo_nome02S[this._parent.item_no];
         }
                                       }
         }

         if (photo_thumbnail03S[this._parent.item_no] != ""){

         _root.hit03.enabled = true;

         _root.hit03.onRelease = function(){
            _root.pic.loadMovie("photos/" + photo_filename03S[this._parent.item_no]);
         }
         if (photo_desc03S[this._parent.item_no] != ""){
         _root.nome03._visible = true;
         _root.nome03.onRelease = function(){
         var infoP3Tween:Tween = new Tween(_root.infoP, "_y", Back.easeOut, _root.infoP._y, 30, 1.5, true);
         _root.infoP.carregaImagem.loadMovie("photos/" + photo_desc03S[posicao]);
         _root.infoP.desc.text = photo_desc03S[this._parent.item_no];
         _root.infoP.tit.text = photo_nome03S[this._parent.item_no];
         }
                                       }
         }

         if (photo_thumbnail04S[this._parent.item_no] != ""){
         _root.hit04.enabled = true;

         _root.hit04.onRelease = function(){
            _root.pic.loadMovie("photos/" + photo_filename04S[this._parent.item_no]);
         }
         if (photo_desc04S[this._parent.item_no] != ""){
            _root.nome04._visible = true;
         _root.nome04.onRelease = function(){
         var infoP4Tween:Tween = new Tween(_root.infoP, "_y", Back.easeOut, _root.infoP._y, 30, 1.5, true);
         _root.infoP.carregaImagem.loadMovie("photos/" + photo_desc04S[posicao]);
         _root.infoP.desc.text = photo_desc04S[this._parent.item_no];
         _root.infoP.tit.text = photo_nome04S[this._parent.item_no];
         }
         }

         }
         /* termina testes */

         //trace(this._parent.item_no);
         var pesqPTweenS:Tween = new Tween(_root.pesquisaBox, "_y", Back.easeIn, _root.pesquisaBox._y, -280, 1, true);
      };
      menu_item_group["menu_item" + i].onEnterFrame = function()
      {
         if (this.over == true)
         {
            this.prevFrame();
         }
         else
         {
            this.nextFrame();
         }
      };


            resultado.resultado.text = searchStringContent;
            //resultado.duplicateMovieClip("resultado" + i, i);
            //this["resultado" + i]._y += resultado._y + (resultado._height+5) * i;
            //this["resultado" + i].label_txt = gallery_name;
            //this["resultado" + i].no = i;


         //entry += "<b><a href = 'http://breathemedia.net/test/deeplinking/#/" + String(content_XML.firstChild.childNodes.attributes.link) + "'>" + searchStringTitle + "</a></b>";
         //entry += "<br>";

         if(searchStringContent.length > 200){
            startEntry = searchStringContent.indexOf(_root.inputSearch.text.toLowerCase());
            if(startEntry + 50 > searchStringContent.length){
               endEntry = searchStringContent.length;
               startEntry = startEntry - 100;                              
               while(searchStringContent.charAt(startEntry) != " "){
                  startEntry--;
               }
               //entry += "..." + searchStringContent.substr(startEntry,(endEntry - startEntry));               
            }else{
               endEntry = startEntry + 50;   
               while(searchStringContent.charAt(endEntry) != " "){
                  endEntry++;
               }
               if(startEntry - 50< 0){
                  startEntry =0;
                  endEntry = startEntry + 100;   
                  while(searchStringContent.charAt(endEntry) != " "){
                     endEntry++;
                  }
                  //entry += searchStringContent.substr(startEntry,(endEntry - startEntry)) + "...";
               }else{
                  startEntry = startEntry - 50;      
                  while(searchStringContent.charAt(startEntry) != " "){
                     startEntry--;
                  }
                  //entry += "..." + searchStringContent.substr(startEntry,(endEntry - startEntry)) + "...";
               }
            }            

         }else{
            //entry += searchStringContent;
         }

         //entry += "<br/><br/>";
         resultsTxt.htmlText = entry;

         search_highlight = new TextFormat();
         search_highlight.color = 0xFF0000;
         search_highlight.italic = true;

         var begin = resultsTxt.indexOf(_root.inputSearch.text.toLowerCase());
         var end = begin + _root.inputSearch.text.length;
         while (begin != -1){
            resultsTxt.setTextFormat(begin, end, search_highlight);
            begin = resultsTxt.text.indexOf(_root.inputSearch.text.toLowerCase(), end);
            end = begin + _root.inputSearch.text.length;
         }         
      }      
      if(checker == 0){
         resultsTxt.htmlText = "Nenhum resultado encontrado para "+_root.inputSearch.text;
         Selection.setFocus("_root.inputSearch");
         Selection.setSelection(0,_root.inputSearch.text.length);
      }
   }   
}

ALGUEM POR FAVOR PODE ME AJUDAR??? L&iacute;ngua

Leonardo Souza Goulart

Compartilhar este post


Link para o post
Compartilhar em outros sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Visitante
Responder

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Processando...

×
×
  • Criar Novo...