Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Vi ringrazio in anticipo (xml+flash da ultrashock)

    Ho scaricato dal sito Ultrashock (Flash / XML search engine ) un esempio per ricercare parole in un file xml (l'esempio funziona bene) ma il file ha 20 records, se ne metto 300 mi compare il messaggio che lo script rallenta il computer (continuare si o no). Come faccio per evitare questo ??.
    Ho provato in vari modi ma non ne capisco molto di action script.
    E' possibile ovviare a questo magari con un preloader ??? è possibile che con solo 300 records il sistema vada in crisi?. In alternativa conoscete qualcosa per un piccolo motore di ricerca all'interno di un sito (magari con un file txt?) Vi ringrazio se qualcuno può darmi una mano

  2. #2
    Probabilmente il tuo file XML ha troppi nodi e così lo script esegue troppi cicli e s'inchioda. I migliori motori di ricerca li ottieni comunque interando con SQL su un database.

  3. #3
    Si è sicuramente così ma ha solo 4 variabili (ne potrei togliere una)
    Ti posto il codice (grazie mille per questa prima risposta)


    stop();
    fscommand("allowscale", "false");
    // flashSearch v1.1b
    // by jonas galvez | jonasgalvez@uol.com.br
    var dbArray = new Array();
    var dbXML = new XML();
    // handle xml
    dbXML.onLoad = function() {
    // variable init
    var title, description, link, keywords;
    var ndRoot = this.firstChild;
    // loop throug the entire xml tree
    for (var i = 0; i<ndRoot.childNodes.length; i++) {
    // ignore white spaces
    if (ndRoot.childNodes[i].nodeName != null) {
    // get node attributes values
    title = ndRoot.childNodes[i].attributes.title;
    description = ndRoot.childNodes[i].attributes.description;
    // loop throug the specific node
    for (var j = 0; j<ndRoot.childNodes[i].childNodes.length; j++) {
    if (ndRoot.childNodes[i].childNodes[j].nodeName == "link") {
    // get node value
    link = ndRoot.childNodes[i].childNodes[j].firstChild.nodeValue;
    } else if (ndRoot.childNodes[i].childNodes[j].nodeName == "keywords") {
    // get the keywords
    keywords = ndRoot.childNodes[i].childNodes[j].firstChild.nodeValue.split("|");
    }
    }
    dbArray.push(new _root.record(title, description, keywords, link));
    // create a new instance of the -=record=- class with these informations
    }
    }
    };
    // record class constructor
    function record(title, description, keywords, link) {
    this.title = title;
    this.description = description;
    this.keywords = keywords;
    this.link = link;
    }
    // search function
    function search(string) {
    // variable init
    var nResults = 0;
    for (var i = 0; i<dbArray.length; i++) {
    // loop throug the keywords Array
    for (j=0; j<dbArray[i].keywords.length; j++) {
    // check if the string matches with a keyword
    if (dbArray[i].keywords[j].toLowerCase() == string) {
    found = true;
    nResults++;
    break;
    }
    }
    if (found) {
    // show the results...
    results += "<a href=\""+dbArray[i].link+"\"><u>"+dbArray[i].title+"</u></a>"+"
    ";
    results += dbArray[i].description+"

    ";
    found = false;
    }
    }
    if (nResults == 0) {
    // if no results...
    results = "No links found. Try again...";
    }
    gotoAndStop(10);
    }
    // loed the xml file
    dbXML.load("database.xml");
    Selection.setFocus("word");
    info = "jonas galvez | <a href=\"mailto:jonasgalvez@uol.com.br\">jonasgalvez @uol.com.br</a>
    ";
    info += "<a href=\"http://www.aranhamagazine.com.br/\">http://www.aranhamagazine.com.br</a>";

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.