Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 14

Discussione: AS & XML

  1. #1
    Utente di HTML.it L'avatar di morfo
    Registrato dal
    Oct 2005
    Messaggi
    85

    AS & XML

    salve sono nuovo in questo forum e cercavo un aiuto riguardante l'argomento AS e XML. Sto costruendo un portfolio e mi servirebbe visualizzare le immagini, oltre che avanti/indietro, facendo scegliere al visitatore la miniatura che vuole lui. Mi chiedevo dopo svariati tentativi qual'è la sintassi da scrivere per richiamare un determinato nodo nel file Xml, a scelta o meglio random: per esempio l'immagine num 6 su 10 tramite un pulsante. Potete aiutarmi per favore? Grazie mille Antonio

  2. #2
    dopo aver caricato e parsizzato l'xml puoi richiamare (ad esempio) il nodo 6 con

    mioxml.childNodes[6].firstChild

    oppure se non sai quanti nodi avrai puoi usare un bel ciclo for.

  3. #3
    Utente di HTML.it L'avatar di morfo
    Registrato dal
    Oct 2005
    Messaggi
    85
    potresti farmi un esempio di un ciclo for? :rollo:

  4. #4
    Utente di HTML.it
    Registrato dal
    Dec 2004
    Messaggi
    641
    considera che dipende tutto anche da come hai fatto il file xml.
    cmq il ciclo for è così:


    myarray=menuxml.firstChild.childNodes;
    for(i=0;i<myarray.length;i++){
    //inserisci il codice
    }

    se però vuoi una cosa ad hoc, devi postare il tuo file xml


  5. #5
    Utente di HTML.it L'avatar di morfo
    Registrato dal
    Oct 2005
    Messaggi
    85
    ok questo è il file xml

    <Slides>
    <slideNode jpegURL="images/1.jpg">uno</slideNode>
    <slideNode jpegURL="images/2.jpg">due</slideNode>
    <slideNode jpegURL="images/3.jpg">tre</slideNode>
    <slideNode jpegURL="images/4.jpg">River Avon</slideNode>
    <slideNode jpegURL="images/5.jpg">Mud and Water</slideNode>
    <slideNode jpegURL="images/6.jpg">Blue knot</slideNode>
    <slideNode jpegURL="images/7.jpg">River Avon</slideNode>
    <slideNode jpegURL="images/8.jpg">River Avon</slideNode>
    <slideNode jpegURL="images/9.jpg">Mud and Water</slideNode>
    <slideNode jpegURL="images/10.jpg">Blue knot</slideNode>

    </Slides>

  6. #6
    Utente di HTML.it
    Registrato dal
    Dec 2004
    Messaggi
    641
    così tiri fuoti tutte le tue immagini con il ciclo for:

    codice:
    filexml = "slide.xml";
    
    mioxml =new XML();
    myarray = new Array();
    mioxml.ignoreWhite = true;
    
    mioxml.load (filexml);
    mioxml.onLoad = caricaImg ;
    function caricaImg(success){
    	if (mioxml.loaded){
    		myarray=mioxml.firstChild.childNodes;
    			for (k=0; k<myarray.length; k++) {
    				immagine = myarray[k].attributes.jpegURL
    				trace(immagine)
    			}
    	}
    }

  7. #7
    Utente di HTML.it L'avatar di morfo
    Registrato dal
    Oct 2005
    Messaggi
    85

    fade out

    OK SEI STATO GENTILISSIMO ma prima di modificare l'AS volevo chiederti, tenendo per buono sempre lo stesso

    filexml,come faccio a fare un fade out dell'immagine quando clicco sul puls next/prev o su una miniatura a caso. Ok

    quando l'immagine arriverà a <1 _alpha, partirà il preload della prossima img con il suo relativo fade in. Ti scrivo

    il cod sorg del file fla:


    stop();
    //Stop everything and set to not visible
    progressBar_mc._visible = false;
    outline_mc._visible = false;
    whiteFrame_mc._visible = false;
    description_mc._visible = false;
    transp_mc._visible = false;

    description_mc.stop();
    transp_mc.stop();

    var bolStart;
    var slides_xml;
    var txtDescription; //Defines the descriptive text to be displayed
    var currentSlideNode;
    var widthDisplay = 550;
    var heightDisplay = 550;
    var pictureBorder = 30;
    var yPosition = 50;

    slides_xml = new XML();
    slides_xml.onLoad = startSlideShow; //start up
    slides_xml.load("slides.xml");
    slides_xml.ignoreWhite = true;

    stop();

    // Show the first slide and intialize variables
    function startSlideShow(success) {
    var rootNode;
    var firstSlideNode;

    bolStart = false; //defines that the description has not been shown

    if (success == true) {
    rootNode = slides_xml.firstChild;
    //Display totalSlides on Scene
    totalSlides = rootNode.childNodes.length;
    firstSlideNode = rootNode.firstChild;
    currentSlideNode = firstSlideNode;
    //Display current slide number on Scene
    currentIndex = 1;
    updateSlide(firstSlideNode);

    }
    }

    // Updates the current slide with new image and text
    function updateSlide(newSlideNode) {
    var imagePath;

    bolStart = false; //defines that the description has not been shown
    bolWhiteFrame = false; //defines if white frame is displayed

    imagePath = newSlideNode.attributes.jpegURL;
    this.createEmptyMovieClip("holder",1);
    holder.loadMovie(imagePath);

    this.onEnterFrame=function() {
    percent = Math.round((this.holder.getBytesLoaded()/this.holder.getBytesTotal())*100);
    if(!isNan(percent))
    {
    //Set progress bar values
    //trace(percent + "% loaded");
    data= "loading xml data"+ percent +"%";
    progressBar_mc._width = percent;
    progressBar_mc._visible = true;
    }
    else {
    progressBar_mc._visible = true;
    progressBar_mc._width = "0";
    //trace("0% loaded");
    }

    if(percent > 99){ //If picture is loaded
    //picture holder movie
    this.holder._x = (widthDisplay - this.holder._width)/2;
    this.holder._y = yPosition + (pictureBorder/2);

    //transparant movie
    transp_mc._width = this.holder._width + pictureBorder;
    transp_mc._height = this.holder._height + pictureBorder;
    transp_mc._y = yPosition;
    transp_mc._x = ((widthDisplay - this.holder._width)/2) - (pictureBorder/2);
    transp_mc._visible = true;
    transp_mc.gotoAndPlay (1);

    transp_mc.swapDepths (5);
    bolWhiteFrame = true;

    if (desctextfade == "true") {
    JPEGButton_mc._x = ((widthDisplay - this.holder._width)/2) -

    (pictureBorder/2);
    JPEGButton.mc._y = yPosition;
    JPEGButton.mc._width = this.holder._width + pictureBorder;
    JPEGButton.mc._height = this.holder._height + pictureBorder;


    }
    else {
    JPEGButton_mc._visible = false;
    }

    description_mc._y = 0;
    description_mc._x = (widthDisplay/2) - 200;

    //Remove progress bar
    progressBar_mc._visible = false;
    outline_mc._visible = false;

    delete this.onEnterFrame;

    //If require description to be displayed and not faded in
    if (desctextfade == "false") {
    DisplayDescription();
    }

    }

    }

    }

    // Event handler for 'Next slide' button
    next_btn.onRelease = function() {
    var nextSlideNode;

    nextSlideNode = currentSlideNode.nextSibling;
    if (nextSlideNode == null) {
    break;
    } else {
    //Display current slide number on Scene
    currentIndex++;
    updateSlide(nextSlideNode);
    currentSlideNode = nextSlideNode;
    }

    };

    // Event handler for 'Previous slide' button
    back_btn.onRelease = function() {

    var previousSlideNode;

    previousSlideNode = currentSlideNode.previousSibling;
    if (previousSlideNode == null) {
    break;
    } else {
    //Display current slide number on Scene
    currentIndex--;
    currentSlideNode = previousSlideNode;
    updateSlide(previousSlideNode);
    }

    };


    Il clip che creo per caricare le immag si chiama "holder".
    Mi dici dove e come ci infilo il cod per il fade out dell'immagine?????????????????? HELPPPPPPPPPPPP!!!

  8. #8
    Utente di HTML.it
    Registrato dal
    Dec 2004
    Messaggi
    641
    non posso testare e quindi non sono sicura ma... prova a mettere questo

    codice:
    // Event handler for 'Next slide' button 
    next_btn.onRelease = function() { 
    
    holder.onEnterFrame = function(){
    	if(currentSlideNode._alpha>0){
    	currentSlideNode._alpha-=5
    	}
    	if(currentSlideNode._alpha<=0){
    	
    		var nextSlideNode; 
    
    		nextSlideNode = currentSlideNode.nextSibling; 
    		if (nextSlideNode == null) { 
    			break; 
    		} else { 
    		//Display current slide number on Scene 
    			currentIndex++; 
    			updateSlide(nextSlideNode); 
    			currentSlideNode = nextSlideNode; 
    		} 
    	}
    }
    };
    sperem.

  9. #9
    Utente di HTML.it L'avatar di morfo
    Registrato dal
    Oct 2005
    Messaggi
    85
    CONTINUA A FUNZIONARE COME PRIMA MA SENZA FADE OUT, CIOE' QUANDO CLICCO NEXT BUTTON SCOMPARE DI NETTO L'IMMAGINE E PARTE IL PRELOAD DELLA SUCCESSIVA

  10. #10
    Utente di HTML.it L'avatar di morfo
    Registrato dal
    Oct 2005
    Messaggi
    85
    Ho inserito il cod che mi hai suggerito per richiamare un nodo in particolare (l'immagine num 6 in questo caso) ma non mi funziona
    Come posso fare????????? :master:

    bt1.onRelease = slides_xml.childNodes[6].firstChild;

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.