Visualizzazione dei risultati da 1 a 3 su 3

Discussione: slideshow da xml

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2011
    Messaggi
    2

    slideshow da xml

    ciao, mi sto
    ho questo codice as3 che lavora su uno slide show da xml che ogni tanto si blocca!!!
    sempre in punti diversi e non riesco a capire cosa non va...
    è scontato dire che non sono un programmatore ... e forse ho osato troppo ...
    vi posto il codice, magari qcuno ha voglia di cimentarsi... grazie in anticipo:


    ...setto tutte le variabili... e poi:
    Codice PHP:
    var path:URLRequest=new URLRequest("canaleMonitor.txt");
    var 
    loaderID:URLLoader = new URLLoader(path);
    var 
    ID_POSTAZIONE:uint;

    //verifica aggiornamento xml ogni 15 minuti
    setInterval(confronto900000);
        
    loaderID.addEventListener(Event.COMPLETEassegnaID);

    function 
    assegnaID(event:Event):void
    {
        var 
    ID:URLVariables = new URLVariables(loaderID.data);
        
    ID_POSTAZIONE ID.idpostazione.split(",");

        var 
    url:String "http://www.****.it/wp-content/monitor/postazioni.php";
        var 
    variables:URLVariables = new URLVariables();
        
    variables.stato 1;
        
    variables.postazione ID_POSTAZIONE;
        var 
    request:URLRequest = new URLRequest(url);
        
    request.data variables;
                       
        try 
        {
            
    sendToURL(request);
        }
        catch (
    e:Error
        {
             
    // handle error here
        
    }
        
        
    xmlLoader.addEventListener(Event.COMPLETExmlLoaded);
        
    xmlLoader.load(new URLRequest("http://www.*****/wp-content/monitor/postazione_"+ID_POSTAZIONE+".xml?"+Math.random()*10000));
    }

    function 
    xmlLoaded(e:Event):void
    {
        
    pianuraXML = new XML(xmlLoader.data);
        
    NumPostTot pianuraXML.post.length();
        
        
    //leggo la variabile tempo su pianuraXML
        
    time pianuraXML. @ time;
        
    //popolo imageArray con URL immagini per gestire componente UILoader
        
    var iA:Number;
        for (
    iA 0iA NumPostTotiA++)
        {
            
    imageArray[iA] = pianuraXML.post.imgUrl[iA];
            
    ////trace("imageArray[iA]"+iA+": "+imageArray[iA]);
        
    }
        
    //chiamo un nuovo post e lo richiamo ogni 20 secondi
        
    caricaSuccessiva();
        
    setInterval(caricaSuccessiva20000);
        
    }

    function 
    caricaSuccessiva()
    {
        
    //controllo la variabile che numera Array
        
    if (nPost >= NumPostTot)
        {
            
    nPost 0;
        }
        
    ////trace("caricaSuccessiva"+nPost);
        // preparo il campo eventi
        
    eventiTxt pianuraXML.post.testo[nPost];
        if (
    eventiTxt == "")
        {
            
    eventiTxt " ";
        }
        
    eventi.htmlText eventiTxt;
        
    //trace("eventi: "+eventiTxt);
        //preparo il campo titolo
        
    titolo.alpha=0;
        
    //trace("alpha titolo 0");
        
    titoloTxt pianuraXML.post.titolo[nPost];
        if (
    titoloTxt == "")
        {
            
    titoloTxt " ";
        }
        
    titolo.htmlText titoloTxt;
        
    //trace("titolo: " + titoloTxt);
        //variabili per tween titolo
        
        
    titolo.width titolo.textWidth+50;
        
    //preparo il campo fotografo
        
    fotografoTxt pianuraXML.post.fotografo[nPost];
        if (
    fotografoTxt == "")
        {
            
    fotografoTxt "© Pianura da Scoprire";
        }
        
    fotografo.htmlText fotografoTxt;
        
    //trace("fotografo: "+fotografoTxt);
        //preparo il campo urlimage
        
    if (imageArray[nPost] == "")
        {
            
    imageArray[nPost] = "http://www.****.it/wp-content/uploads/2011/10/bianca.jpg";
        }
        
    //trace("image: "+imageArray[nPost]);
        
    alterna alterna 1;
        if (
    alterna 1)
        {
            
    alterna 0;
        }
        
    //trace("alterna: "+alterna);
        
    alternaLoader();
    }

    function 
    alternaLoader()
    {
        if (
    alterna == 1
          { 
            
    loadFoto1 = new Loader();
            
    loadFoto1.x=0;
            
    loadFoto1.y=110;
            
    loadFoto1.contentLoaderInfo.addEventListener(Event.COMPLETEmostraEventi1);
            
    loadFoto1.load(new URLRequest(imageArray[nPost]));
          } 
          else 
          { 
            
    loadFoto2 = new Loader();
            
    loadFoto2.x=0;
            
    loadFoto2.y=110;
            
    loadFoto2.contentLoaderInfo.addEventListener(Event.COMPLETEmostraEventi2);
            
    loadFoto2.load(new URLRequest(imageArray[nPost]));
          } 
    }

    function 
    mostraEventi1(e:Event):void
    {
        
    //trace("mostra eventi 1");
        
    if(loadFoto2 != null)
        { 
               
    removeChild(loadFoto2);
            
    //trace("rimuovo loader 2");
        
    }
        
    larghezzaL1 e.target.width;
        
    proporzione 1920 larghezzaL1;
        
    loadFoto1.scaleX loadFoto1.scaleY proporzione;
        
    addChildAt(loadFoto10);
        
    //trace("aggiungo loader 1");
        
    TweenFoto1 = new Tween(loadFoto1,'alpha',None.easeIn,0,1,1,true);
        
    TweenEventi = new Tween(eventi"x"Strong.easeOut192013601true);
        
    TweenTitolo = new Tween(titolo'alpha',None.easeIn,0,1,1,true);
        
    TweenFotografo = new Tween(fotografo"x"Strong.easeOut192013601true);
        
    TimerEventi();
        
    loadFoto1.contentLoaderInfo.removeEventListener(Event.COMPLETEmostraEventi1);
        
    nPost++;
    }

    function 
    mostraEventi2(e:Event):void
    {
        
    //trace("mostra eventi 2");
        
    if(loadFoto1 != null)
        { 
               
    removeChild(loadFoto1);
            
    //trace("rimuovo loader 1");
        
    }
        
    larghezzaL2 e.target.width;
        
    proporzione2 1920 larghezzaL2;
        
    loadFoto2.scaleX loadFoto2.scaleY proporzione2;
        
    addChildAt(loadFoto20);
        
    //trace("aggiungo loader 2");
        
    TweenFoto2 = new Tween(loadFoto2,'alpha',None.easeIn,0,1,1,true);
        
    TweenEventi = new Tween(eventi"x"Strong.easeOut192013601true);
        
    TweenTitolo = new Tween(titolo'alpha',None.easeIn,0,1,1,true);
        
    TweenFotografo = new Tween(fotografo"x"Strong.easeOut192013601true);
        
    TimerEventi();
        
    loadFoto1.contentLoaderInfo.removeEventListener(Event.COMPLETEmostraEventi2);
        
    nPost++;
    }

    function 
    TimerEventi() 
    {
        var 
    myTimer:Timer = new Timer(100001);
        
    myTimer.addEventListener("timer"rimuoviEventi);
        
    myTimer.start();
    }

    function 
    rimuoviEventi(event:TimerEvent):void 
    {
        
    TweenEventi = new Tween(eventi"x"Strong.easeOut156019201true);
        
    TweenFotografo = new Tween(fotografo"x"Strong.easeOut156019201true);
        
    //trace("rimuovo eventi");
    }


    function 
    confronto()
    {        
        var 
    url:String "http://www.*****/wp-content/monitor/postazioni.php";
        var 
    variables:URLVariables = new URLVariables();
        
    variables.stato 1;
        
    variables.postazione ID_POSTAZIONE;
        var 
    request:URLRequest = new URLRequest(url);
        
    request.data variables;
               
        try 
        {
            
    sendToURL(request);
        }
        catch (
    e:Error
        {
             
    // handle error here
        
    }

        
        
    xmlLoaderConfronto.addEventListener(Event.COMPLETExmlLoadedConfronto);
        
    xmlLoaderConfronto.load(new URLRequest("http://www.*****/wp-content/monitor/postazione_"+ID_POSTAZIONE+".xml?"+Math.random()*10000));
    }
        
    function 
    xmlLoadedConfronto(event:Event):void
    {                
                    
        
    pianuraXMLConfronto = new XML(xmlLoaderConfronto.data);
        
    timeConfronto pianuraXMLConfronto.@time;
        
        
        if (
    timeConfronto time)
        {
            
    //popolo imageArray con URL image Post
            
    var iAConfronto:Number;
            
    NumPostTot pianuraXMLConfronto.post.length();
            for (
    iAConfronto 0iAConfronto NumPostTotiAConfronto++)
            {
                
    imageArray[iAConfronto] = pianuraXML.post.imgUrl[iAConfronto];
            }
                
            
    pianuraXML = new XML();
            
    pianuraXML pianuraXMLConfronto;
            
    nPost=0;
            
    time timeConfronto;
        }

    ...seguono altre azioni per la gestione dell'orologio e della grafica...

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Con tutto il rispetto mamux, la quantità di codice da leggere e interpretare è decisamente elevata e non è possibile che una persona riesca a dirti cosa non va.

    Ti consiglierei magari di inserire in una pagina web la galleria generata, con anche un link per scaricare il progetto in FLA (o quello che usi), così che chi si prendesse la briga di risponderti, possa quanto meno tentare di replicare l'errore di cui parli nel post.

    PS. ho aggiunto i tag per il codice nel tuo messaggio, così è più leggibile.

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2011
    Messaggi
    2
    grazie mille. lo farò al più presto.
    mamux

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.