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

    Non visualizza le immagini estratte da un file XML

    Salve ragazzi buongiorno. Premetto che non sono molto esperto di Action Script e sto dando una mano al collega.

    Ho un file che mi dovrebbe caricare come sfondo delle immagini tramite file XML solo che non me le mostra. Dall' output non ho nessun errore relativo al caricamento del file XML.

    Ecco il codice del file flash:
    codice:
    function parseXML(sucess)
    {
        if (sucess)
        {
            maxImages = xml2as.images[0].image.length - 1;
            preload = xml2as.images[0].preload;
            speed = Number(xml2as.images[0].speed);
            if (!xml2as.images[0].speed)
            {
                speed = 2;
            } // end if
            if (preload)
            {
                preloadImages();
            }
            else
            {
                loadImages();
            } // end else if
        }
        else
        {
            trace ("Error loading XML!");
        } // end else if
    } // End of the function
    function preloadImages()
    {
        for (var _loc1 = 0; _loc1 < preload; ++_loc1)
        {
            var _loc2 = mainTimeline.imagesHolder.createEmptyMovieClip("clip_" + _loc1, mainTimeline.imagesHolder.getNextHighestDepth());
            var _loc3 = String(xml2as.images[0].folderpath) + String(xml2as.images[0].image[_loc1].url);
            loadQueue.addToQueue(_loc3, _loc2, false, false);
        } // end of for
        loadQueue.startLoad();
    } // End of the function
    function loadImages()
    {
        if (preload)
        {
            for (var _loc1 = preload; _loc1 < xml2as.images[0].image.length; ++_loc1)
            {
                var _loc2 = mainTimeline.imagesHolder.createEmptyMovieClip("clip_" + _loc1, mainTimeline.imagesHolder.getNextHighestDepth());
                var _loc3 = String(xml2as.images[0].folderpath) + String(xml2as.images[0].image[_loc1].url);
                loadQueue2.addToQueue(_loc3, _loc2, false, false);
            } // end of for
        }
        else
        {
            for (var _loc1 = 0; _loc1 < xml2as.images[0].image.length; ++_loc1)
            {
                _loc2 = mainTimeline.imagesHolder.createEmptyMovieClip("clip_" + _loc1, mainTimeline.imagesHolder.getNextHighestDepth());
                _loc3 = String(xml2as.images[0].folderpath) + String(xml2as.images[0].image[_loc1].url);
                loadQueue2.addToQueue(_loc3, _loc2, false, false);
            } // end of for
        } // end else if
        loadQueue2.startLoad();
    } // End of the function
    function startAnimation()
    {
        var _loc1 = mainTimeline.imagesHolder["clip_" + imageIterator];
        var _loc2 = new Object();
        _loc2.y = 0;
        _loc2.x = 0;
        _loc1._x = _loc2.x;
        _loc1._y = _loc2.y;
        _loc1._alpha = 0;
        _loc1._visible = true;
        var _loc5 = getOldImageIterator();
        var _loc3 = mainTimeline.imagesHolder["clip_" + _loc5];
        var _loc4 = Number(xml2as.images[0].image[imageIterator].time);
        if (!_loc1.loaded)
        {
            trace ("clip not yet loaded , come back later");
            setTimeout(mainTimeline, "startAnimation", 400);
            return;
        } // end if
        caurina.transitions.Tweener.addTween(_loc3, {delay: 2.000000E-001, time: speed, _alpha: 0, transition: tweenerTransition, onComplete: hideMc, onCompleteParams: [_loc3]});
        caurina.transitions.Tweener.addTween(_loc1, {delay: 2.000000E-001, time: speed, _alpha: 100, transition: tweenerTransition});
        caurina.transitions.Tweener.addCaller(mainTimeline, {delay: speed, time: _loc4, count: 1, onComplete: startAnimation});
        increaseIterator();
    } // End of the function
    function showMc(mc)
    {
        mc._visible = true;
    } // End of the function
    function hideMc(mc)
    {
        mc._visible = false;
    } // End of the function
    function chooseRandomDir()
    {
        var _loc1 = Math.floor(Math.random() * directionArray.length);
        return (directionArray[_loc1]);
    } // End of the function
    function increaseIterator()
    {
        ++imageIterator;
        if (imageIterator > maxImages)
        {
            imageIterator = 0;
        } // end if
    } // End of the function
    function setBgSize(mc)
    {
        var _loc2 = mc._width / mc._height;
        var _loc3 = Stage.width / Stage.height;
        if (_loc3 >= _loc2)
        {
            mc._width = Stage.width;
            mc._height = Stage.width / _loc2;
        }
        else
        {
            mc._height = Stage.height;
            mc._width = Stage.height * _loc2;
        } // end else if
    } // End of the function
    function getOldImageIterator()
    {
        var _loc1 = imageIterator;
        --_loc1;
        if (_loc1 < 0 && firstTimeLoaded != true)
        {
            _loc1 = maxImages;
        } // end if
        firstTimeLoaded = false;
        return (_loc1);
    } // End of the function
    caurina.transitions.properties.DisplayShortcuts.init();
    Stage.align = "TL";
    Stage.scaleMode = "noScale";
    var xml2as = new Object();
    var xmlURL = "images.xml";
    gs.dataTransfer.XMLParser.load(xmlURL, parseXML, xml2as);
    this._lockroot = true;
    mainTimeline = this;
    loader._x = Stage.width / 2 - loader._width / 2;
    loader._y = Stage.height / 2 - loader._height / 2;
    var imageIterator = 0;
    var maxImages = 0;
    var tweenerTransition = "easeInoutQuint";
    var speed;
    var time;
    var preload = undefined;
    var loadQueue = new com.dsky.QueueManager();
    var loadL = new Object();
    loadL.onQueueProgress = function (info)
    {
        mainTimeline.loader.bar._xscale = info.percent;
        mainTimeline.loader.text2MC.loadText.text = Math.round(info.percent) + "%";
    };
    loadL.onLoadStart = function (target)
    {
        target._visible = false;
        target._x = Stage.width;
    };
    loadL.onLoadInit = function (target)
    {
        target.loaded = true;
        target._visible = false;
        target._alpha = 0;
        setBgSize(target);
    };
    loadL.onAllLoaded = function (info)
    {
        loadQueue.clearQueue();
        caurina.transitions.Tweener.addTween(loader, {_autoAlpha: 0, _y: loader._y + 40, time: 1, transition: "easeOutExpo"});
        if (preload)
        {
            startAnimation();
            loadImages();
        } // end if
    };
    loadQueue.addListener(loadL);
    var loadQueue2 = new com.dsky.QueueManager();
    var queueL2 = new Object();
    loadQueue2.addListener(queueL2);
    queueL2.onLoadStart = function (target)
    {
        target._visible = false;
        target._x = Stage.width;
    };
    queueL2.onLoadInit = function (target)
    {
        target.loaded = true;
        target._visible = false;
        target._alpha = 0;
        setBgSize(target);
        target._x = Stage.width;
    };
    queueL2.onQueueProgress = function (info)
    {
        mainTimeline.loader.bar._xscale = info.percent;
    };
    queueL2.onAllLoaded = function ()
    {
        loadQueue2.clearQueue();
        if (preload)
        {
            return;
        } // end if
        caurina.transitions.Tweener.addTween(loader, {_autoAlpha: 0, time: 1, _y: loader._y + 40, transition: "easeOutExpo"});
        startAnimation();
    };
    var firstTimeLoaded = true;
    var stageL = new Object();
    stageL.onResize = function ()
    {
        for (var _loc1 = 0; _loc1 < xml2as.images[0].image.length; ++_loc1)
        {
            var _loc2 = mainTimeline.imagesHolder["clip_" + _loc1];
            setBgSize(_loc2);
        } // end of for
        com.dsky.Align.center(loader);
    };
    Stage.addListener(stageL);
    //infoClip.fullButt.onPress = function ()
    //{
      //  if (Stage.displayState == "normal")
        //{
          //  Stage.displayState = "fullScreen";
        //}
        //else
        //{
          //  Stage.displayState = "normal";
        //} // end else if
    //};
    Qiesto è il file XML:
    codice:
      <?xml version="1.0" encoding="utf-8" ?> 
    - <data>
    - <images folderpath="images/" preload="3" speed="5">
      <image url="immagine1.jpg" time="3" /> 
      <image url="immagine2.jpg" time="3" /> 
      <image url="immagine3.jpg" time="3" /> 
      <image url="immagine4.jpg" time="3" /> 
      <image url="immagine5.jpg" time="3" /> 
      <image url="immagine6.jpg" time="3" /> 
      <image url="immagine7.jpg" time="3" /> 
      <image url="immagine8.jpg" time="3" /> 
      </images>
      </data>
    Ho controllato i percorsi e sono corretti, errori quando creo l'swf non ne ho.
    Da cosa potrebbe dipendere?
    :master:
    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  2. #2
    Moderatore di CSS L'avatar di KillerWorm
    Registrato dal
    Apr 2004
    Messaggi
    5,780
    Ciao.
    Da una veloce analisi dello script ho visto che stai utilizzando la classe "caurina" per le transizioni ma non vedo nessun import di tale classe.

    Non ho fatto nessuna prova del tuo script ma dato che stai utilizzando quella classe ed essendo una classe esterna è necessario importarla nel frame in cui la stai utilizzando.
    Installa Forum HTML.it Toolset per una fruizione ottimale del Forum

  3. #3
    Ho provato ad importare la classe completa:

    codice:
    function parseXML(sucess)
    {
        if (sucess)
        {
            maxImages = xml2as.images[0].image.length - 1;
            preload = xml2as.images[0].preload;
            speed = Number(xml2as.images[0].speed);
            if (!xml2as.images[0].speed)
            {
                speed = 2;
            } // end if
            if (preload)
            {
                preloadImages();
            }
            else
            {
                loadImages();
            } // end else if
        }
        else
        {
            trace ("Error loading XML!");
        } // end else if
    } // End of the function
    function preloadImages()
    {
        for (var _loc1 = 0; _loc1 < preload; ++_loc1)
        {
            var _loc2 = mainTimeline.imagesHolder.createEmptyMovieClip("clip_" + _loc1, mainTimeline.imagesHolder.getNextHighestDepth());
            var _loc3 = String(xml2as.images[0].folderpath) + String(xml2as.images[0].image[_loc1].url);
            loadQueue.addToQueue(_loc3, _loc2, false, false);
        } // end of for
        loadQueue.startLoad();
    } // End of the function
    function loadImages()
    {
        if (preload)
        {
            for (var _loc1 = preload; _loc1 < xml2as.images[0].image.length; ++_loc1)
            {
                var _loc2 = mainTimeline.imagesHolder.createEmptyMovieClip("clip_" + _loc1, mainTimeline.imagesHolder.getNextHighestDepth());
                var _loc3 = String(xml2as.images[0].folderpath) + String(xml2as.images[0].image[_loc1].url);
                loadQueue2.addToQueue(_loc3, _loc2, false, false);
            } // end of for
        }
        else
        {
            for (var _loc1 = 0; _loc1 < xml2as.images[0].image.length; ++_loc1)
            {
                _loc2 = mainTimeline.imagesHolder.createEmptyMovieClip("clip_" + _loc1, mainTimeline.imagesHolder.getNextHighestDepth());
                _loc3 = String(xml2as.images[0].folderpath) + String(xml2as.images[0].image[_loc1].url);
                loadQueue2.addToQueue(_loc3, _loc2, false, false);
            } // end of for
        } // end else if
        loadQueue2.startLoad();
    } // End of the function
    function startAnimation()
    {
        var _loc1 = mainTimeline.imagesHolder["clip_" + imageIterator];
        var _loc2 = new Object();
        _loc2.y = 0;
        _loc2.x = 0;
        _loc1._x = _loc2.x;
        _loc1._y = _loc2.y;
        _loc1._alpha = 0;
        _loc1._visible = true;
        var _loc5 = getOldImageIterator();
        var _loc3 = mainTimeline.imagesHolder["clip_" + _loc5];
        var _loc4 = Number(xml2as.images[0].image[imageIterator].time);
        if (!_loc1.loaded)
        {
            trace ("clip not yet loaded , come back later");
            setTimeout(mainTimeline, "startAnimation", 400);
            return;
        } // end if
    	import caurina.transitions.* 
        caurina.transitions.Tweener.addTween(_loc3, {delay: 2.000000E-001, time: speed, _alpha: 0, transition: tweenerTransition, onComplete: hideMc, onCompleteParams: [_loc3]});
        caurina.transitions.Tweener.addTween(_loc1, {delay: 2.000000E-001, time: speed, _alpha: 100, transition: tweenerTransition});
        caurina.transitions.Tweener.addCaller(mainTimeline, {delay: speed, time: _loc4, count: 1, onComplete: startAnimation});
        increaseIterator();
    } // End of the function
    function showMc(mc)
    {
        mc._visible = true;
    } // End of the function
    function hideMc(mc)
    {
        mc._visible = false;
    } // End of the function
    function chooseRandomDir()
    {
        var _loc1 = Math.floor(Math.random() * directionArray.length);
        return (directionArray[_loc1]);
    } // End of the function
    function increaseIterator()
    {
        ++imageIterator;
        if (imageIterator > maxImages)
        {
            imageIterator = 0;
        } // end if
    } // End of the function
    function setBgSize(mc)
    {
        var _loc2 = mc._width / mc._height;
        var _loc3 = Stage.width / Stage.height;
        if (_loc3 >= _loc2)
        {
            mc._width = Stage.width;
            mc._height = Stage.width / _loc2;
        }
        else
        {
            mc._height = Stage.height;
            mc._width = Stage.height * _loc2;
        } // end else if
    } // End of the function
    function getOldImageIterator()
    {
        var _loc1 = imageIterator;
        --_loc1;
        if (_loc1 < 0 && firstTimeLoaded != true)
        {
            _loc1 = maxImages;
        } // end if
        firstTimeLoaded = false;
        return (_loc1);
    } // End of the function
    caurina.transitions.properties.DisplayShortcuts.init();
    Stage.align = "TL";
    Stage.scaleMode = "noScale";
    var xml2as = new Object();
    var xmlURL = "images.xml";
    gs.dataTransfer.XMLParser.load(xmlURL, parseXML, xml2as);
    this._lockroot = true;
    mainTimeline = this;
    loader._x = Stage.width / 2 - loader._width / 2;
    loader._y = Stage.height / 2 - loader._height / 2;
    var imageIterator = 0;
    var maxImages = 0;
    var tweenerTransition = "easeInoutQuint";
    var speed;
    var time;
    var preload = undefined;
    var loadQueue = new com.dsky.QueueManager();
    var loadL = new Object();
    loadL.onQueueProgress = function (info)
    {
        mainTimeline.loader.bar._xscale = info.percent;
        mainTimeline.loader.text2MC.loadText.text = Math.round(info.percent) + "%";
    };
    loadL.onLoadStart = function (target)
    {
        target._visible = false;
        target._x = Stage.width;
    };
    loadL.onLoadInit = function (target)
    {
        target.loaded = true;
        target._visible = false;
        target._alpha = 0;
        setBgSize(target);
    };
    loadL.onAllLoaded = function (info)
    {
        loadQueue.clearQueue();
        caurina.transitions.Tweener.addTween(loader, {_autoAlpha: 0, _y: loader._y + 40, time: 1, transition: "easeOutExpo"});
        if (preload)
        {
            startAnimation();
            loadImages();
        } // end if
    };
    loadQueue.addListener(loadL);
    var loadQueue2 = new com.dsky.QueueManager();
    var queueL2 = new Object();
    loadQueue2.addListener(queueL2);
    queueL2.onLoadStart = function (target)
    {
        target._visible = false;
        target._x = Stage.width;
    };
    queueL2.onLoadInit = function (target)
    {
        target.loaded = true;
        target._visible = false;
        target._alpha = 0;
        setBgSize(target);
        target._x = Stage.width;
    };
    queueL2.onQueueProgress = function (info)
    {
        mainTimeline.loader.bar._xscale = info.percent;
    };
    queueL2.onAllLoaded = function ()
    {
        loadQueue2.clearQueue();
        if (preload)
        {
            return;
        } // end if
        caurina.transitions.Tweener.addTween(loader, {_autoAlpha: 0, time: 1, _y: loader._y + 40, transition: "easeOutExpo"});
        startAnimation();
    };
    var firstTimeLoaded = true;
    var stageL = new Object();
    stageL.onResize = function ()
    {
        for (var _loc1 = 0; _loc1 < xml2as.images[0].image.length; ++_loc1)
        {
            var _loc2 = mainTimeline.imagesHolder["clip_" + _loc1];
            setBgSize(_loc2);
        } // end of for
        com.dsky.Align.center(loader);
    };
    Stage.addListener(stageL);
    //infoClip.fullButt.onPress = function ()
    //{
       // if (Stage.displayState == "normal")
       // {
       //     Stage.displayState = "fullScreen";
       // }
       // else
       // {
       //     Stage.displayState = "normal";
       // } // end else if
    //};
    Solo che il risultato non cambia. Ho notato anche che esportando in AS 2.0 l'esecuzione degli altri filmati (per esmpio la movimentazione del menu) è regolare mentre in AS 3.0 all' output mi genera molti errori e tutte le altre animazioni sballano.

    Se non sbaglio la classe Caurina funzionava con AS 3.0 oppure anche con il 2.0?

    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  4. #4
    Moderatore di CSS L'avatar di KillerWorm
    Registrato dal
    Apr 2004
    Messaggi
    5,780
    Il tuo script è in AS2 quindi è improbabile che funzioni esportando per AS3.
    La classe caurina esiste sia per AS2 sia per AS3, dovrai quindi utilizzare quella che serve a te.
    Qui puoi scaricare le varie versioni.
    http://code.google.com/p/tweener/downloads/list.
    Installa Forum HTML.it Toolset per una fruizione ottimale del Forum

  5. #5
    Moderatore di CSS L'avatar di KillerWorm
    Registrato dal
    Apr 2004
    Messaggi
    5,780
    Giusto per puntualizzare, l'istruzione import non è necessaria in questo caso dato che sullo script sono indicati per intero i nomi di classe.

    Dando comunque una lettura più attenta al tuo script ho notato che oltre caurina sono utilizzate altre classi e pacchetti tra cui "gs.dataTransfer" e "com.dsky.QueueManager".
    Ovviamente perchè il tutto funzioni è necessario che queste classi esistano e siano installate opportunamente sul sistema.
    Installa Forum HTML.it Toolset per una fruizione ottimale del Forum

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.