Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1

    sommare e non concatenare du variabili

    ricevo da un file xml la variabile xmlpag (che vale 150) poi a questo vorrei sommarci la variabile adjust (che vale 6) così:

    xmlpag1=this.childNodes[i].attributes.xmlpag+adjust;

    però mi da 1506 non 156

    ho provato a fare anche una terza variabile:

    somma=xmlpag1+adjust ma non ne esco

    ho provato anche a dichiarare var xmlpag1:Number=this.childNodes[i].attributes.xmlpag+adjust;

    ma non funz

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    hai provato a fare così
    var xmlpag1:Number = Number(this.childNodes[i].attributes.xmlpag)+Number(adjust);

  3. #3
    Originariamente inviato da and80
    hai provato a fare così
    var xmlpag1:Number = Number(this.childNodes[i].attributes.xmlpag)+Number(adjust);
    così mi dà "undefined"

  4. #4
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da eloderma
    così mi dà "not defined"
    oh, benone ma adjust è dichiarata da qualche parte? e in che modo?

  5. #5
    Codice PHP:
    leggi = function () {
        
    nuovo = new XML();
        
    nuovo.ignoreWhite true;
        
    file="img.xml";
        
    path="./img/";
        
    //path="./data/top_class/img/";
        
    nuovo.load(path+file);
        
    nuovo.onLoad = function(success) {
            if (
    success) {
                
    tot this.childNodes.length;
                
    etichetta1.text this.childNodes[i].attributes.descrizione;
                
    box1.loadMovie(path+this.childNodes[i].attributes.photo);
                
    //xmlpag1=this.childNodes[i].attributes.xmlpag+adjust;
                
    var xmlpag1:Number Number(this.childNodes[i].attributes.xmlpag+adjust);
                
                
    etichetta2.text this.childNodes[i+1].attributes.descrizione;
                
    box2.loadMovie(path+this.childNodes[i+1].attributes.photo);
                
    xmlpag2=this.childNodes[i+1].attributes.xmlpag;
                
                
    etichetta3.text this.childNodes[i+2].attributes.descrizione;
                
    box3.loadMovie(path+this.childNodes[i+2].attributes.photo);
                
    xmlpag3=this.childNodes[i+2].attributes.xmlpag;
                
                
    etichetta4.text this.childNodes[i+3].attributes.descrizione;
                
    box4.loadMovie(path+this.childNodes[i+3].attributes.photo);
                
    xmlpag4=this.childNodes[i+3].attributes.xmlpag;
                
    //trace(i);
            
    } else {
                
    trace("errore di lettura");
            }
        };
    };

    var 
    0;
    var 
    adjust 6;
    leggi();

    su.onRelease = function() {
        
    i--;
        if (
    i>=0) {
            
    leggi();
        } else {
            
    0;
        }
    };
    giu.onRelease = function() {
        
    i++;
        if (
    i+3<tot) {
            
    leggi();
        } else {
            
    tot-4;
        }
    }; 

  6. #6
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    puoi fare una prova? fai un trace di adjust in prossimità dl punto in cui la utilizzi e dimmi se ti restituisce il valore corretto

  7. #7
    fatto, mi dice 6

    secondo me il problema è come prelevare la variabile numerica dal file xml ma è la prima volta che mi cimento...

  8. #8
    infatti se faccio adjust*2 mi da 12

  9. #9
    così funzia:

    xmlpag1 = Number(this.childNodes[i].attributes.xmlpag)+adjust;


    grazie

  10. #10
    moltiplica la variabile che leggi per 1

    stringa*1+intero

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.