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

    Valori in box Testo,,, XML

    Codice ActionScript

    xmlData = new XML();
    xmlData.ignoreWhite = true;
    idnews = new Array();
    notizia = new Array();
    xmlData.onLoad = parse_data;
    xmlData.load("Ciao.xml");
    function parse_data(success) {
    if (success == true) {
    xmlData = parseXmlToArray(xmlData);

    } else {
    trace("Error:\nThe XML document did not load properly.\n");
    }
    }
    function multiNodeObject() {
    }
    multiNodeObject.prototype = new Object();
    multiNodeObject.prototype.length = function() {
    var count = 0;
    for (var name in this) {
    var addCount = true;
    for (var i = 0; i<name.length; i++) {
    if (name.charCodeAt(i)<48 || name.charCodeAt(i)>57) {
    addCount = false;
    }
    }
    if (addCount) {
    count++;
    }
    }
    return count;
    };
    function parseXmlToArray(xm) {
    // temporary object that will be returned
    var temp_obj = new Object();
    // Checks to see if the current xml object has any children. If it doesn't, There isn't data here and the function will end.
    if (xm.hasChildNodes() && xm.childNodes.length>1) {
    if (xm.nodeName != null) {
    temp_obj[xm.nodeName] = new multiNodeObject();
    for (var i = 0; i<xm.childNodes.length; i++) {
    temp_obj[xm.nodeName][i] = parseXmlToArray(xm.childNodes[i]);
    }
    if (xm.attributes) {
    for (var name in xm.attributes) {
    temp_obj[xm.nodeName][name] = xm.attributes[name];
    }
    }
    } else if (xm.nodeName == null) {
    for (var i = 0; i<xm.childNodes.length; i++) {
    temp_obj[xm.childNodes[i].nodeName] = new multiNodeObject();
    for (var k = 0; k<xm.childNodes[i].childNodes.length; k++) {
    temp_obj[xm.childNodes[i].nodeName][k] = parseXmlToArray(xm.childNodes[i].childNodes[k]);
    }
    if (xm.childNodes[i].attributes) {
    for (var name in xm.childNodes[i].attributes) {
    temp_obj[xm.childNodes[i].nodeName][name] = xm.childNodes[i].attributes[name];
    }
    }
    }
    }
    } else if (xm.hasChildNodes() && xm.childNodes.length == 1) {
    if (xm.firstChild.nodeType == 1) {
    temp_obj[xm.firstChild.nodeName] = new multiNodeObject();
    for (var j = 0; j<=xm.childNodes.length; j++) {
    temp_obj[xm.firstChild.nodeName][j] = parseXmlToArray(xm.firstChild.childNodes[j]);
    }
    if (xm.firstChild.attributes) {
    var temp1 = new Object();
    for (var name in xm.firstChild.attributes) {
    temp_obj[xm.firstChild.nodeName][name] = xm.firstChild.attributes[name];
    }
    }
    } else if (xm.firstChild.nodeType == 3) {
    var temp2 = new Object();
    temp2["value"] = xm.firstChild.nodeValue;
    if (xm.attributes) {
    for (var name in xm.attributes) {
    temp2[name] = xm.attributes[name];
    }
    }
    //else if(i=2){null;}
    temp_obj[xm.nodeName] = temp2;
    }
    }
    // Outputs the current nodes' attribuets array to the xml_data textbox
    return temp_obj;
    }


    Questo invece il mio XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <notizie>
    <notizia id="1">
    <titolo>Cagliari</titolo>
    <sottotitolo>Roma</sottotitolo>
    <testo>Ciao mi chiamo Vito e sto provando ancora il mio XML</testo>
    <foto>vito.jpg</foto>
    </notizia>
    <notizia id="2">
    <titolo>Cagliari</titolo>
    <sottotitolo>Roma</sottotitolo>
    <testo>Ciao mi chiamo Francesco e sto provando ancora il mio XML</testo>
    <foto>peppa.jpg</foto>
    </notizia>
    <notizia id="3">
    <titolo>MA dai</titolo>
    <sottotitolo>ma che sta a fa</sottotitolo>
    <testo>questo e in grassetto sono andato a capo</testo>
    <foto>rocco.jpg</foto>
    </notizia>
    </notizie>



    Sapreste dirmi come faccio a prendere i valori "id notizia", "titolo", "sottotitolo", "testo" e buttarli in un campo di testo?

  2. #2

  3. #3
    Ma nessuno può farmi per favore un esempio veloce su questa funzione. Mi serve urgente. Proprio prendere i valori che ho detto e buttarli nel campo di testo e poi buttare foto un un movie clip..

  4. #4
    Utente di HTML.it L'avatar di negatyve
    Registrato dal
    Feb 2001
    Messaggi
    9,479
    Come li devi formattare?

  5. #5
    Praticamente devo metterli un un unico box di testo e formattarli così :

    Titolo
    Sottotitolo

    TestoTestoTestoTesto
    TestoTestoTestoTesto
    TestoTestoTesto
    TestoTestoTestoTesto
    TestoTestoTestoTesto
    TestoTestoTestoTesto
    TestoTestoTestoTesto
    TestoTestoTestoTesto

    Immagine

    Non sto capendo come estrapolare questi dati. Conta che poi sarà una pagina esterna Asp o Php a decidere quale id caricare.

    Ti prego aiutami mi sono bloccato.

  6. #6
    Ah l'immagine in un clip a parte non nel box di testo.

  7. #7
    Utente di HTML.it L'avatar di negatyve
    Registrato dal
    Feb 2001
    Messaggi
    9,479
    Che versione del flash stai usando?

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.