xml dynamique photogallery Preloader?

  • roarmeow
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Oct 12, 2004
  • Messages: 861
  • Loc: BKNY
  • Status: Offline

Message Mai 22nd, 2005, 11:14 am

Bon, alors maintenant Ive a obtenu cette im photogallery de travail sur...et il s'enfuit d'un document XML...et je veux créer une sorte de preloader qui peut détecter tous les fichiers. jpgs d'être chargés par l'intermédiaire du doc xml et suivre leurs progrès.

Ainsi, pour un, Theres un certain type d'indicateur que quelque chose que le chargement et je tiens aussi à construire dans une sorte de fonction au centre de chaque image dans le cadre dans lequel theyre cours de chargement.

si quelqu'un peut aider, s'il vous plaît faire.

merci d'avance.

ActionScript est le suivant:

Code: [ Select ]
myMain = new XML();
myMain.ignoreWhite = true;
myMain.load("fashion.xml");
myMain.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
_global.imagenum=numimages;
spacing = 465;
for (i=0; i<numimages; i++) {
pictHolder = this.firstChild.childNodes[i];
mainHolder = loader.createEmptyMovieClip("loaders"+i, i);
mainHolder._x = i*spacing;
mainHolder.title = pictHolder.attributes.title;
mainHolder.main = pictHolder.attributes.main;
mainLoader = mainHolder.createEmptyMovieClip("main_image"+i, i);
mainLoader.loadMovie(pictHolder.attributes.main);
}
};
  1. myMain = new XML();
  2. myMain.ignoreWhite = true;
  3. myMain.load("fashion.xml");
  4. myMain.onLoad = function(success) {
  5. numimages = this.firstChild.childNodes.length;
  6. _global.imagenum=numimages;
  7. spacing = 465;
  8. for (i=0; i<numimages; i++) {
  9. pictHolder = this.firstChild.childNodes[i];
  10. mainHolder = loader.createEmptyMovieClip("loaders"+i, i);
  11. mainHolder._x = i*spacing;
  12. mainHolder.title = pictHolder.attributes.title;
  13. mainHolder.main = pictHolder.attributes.main;
  14. mainLoader = mainHolder.createEmptyMovieClip("main_image"+i, i);
  15. mainLoader.loadMovie(pictHolder.attributes.main);
  16. }
  17. };
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Mai 22nd, 2005, 11:14 am

  • lostinbeta
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Juin 26, 2003
  • Messages: 1402
  • Loc: Philadelphia, PA
  • Status: Offline

Message Mai 22nd, 2005, 2:37 pm

Ok, eh bien il ya environ un million et une façons dont vous pouvez configurer cette fonction, mais le concept est toujours le même...si Im gonna go avec l'idée de base.

Vous aurez d'abord besoin de lancer un onEnterFrame...de sorte qu'il puisse constamment vérifier la valeur de ce qui est chargé. Le problème avec cela est que...bien...vous ne pouvez pas joindre le onEnterFrame pour le clip qui se charge à quelque chose puisque les actions d'être écrasés par le chargement de contenu à la pince.

Ainsi, il semble que vous ayez à celle couverte par la création d'un clip mainHolder et un clip mainLoader l'intérieur de ce...de sorte que vous pouvez exécuter le préchargement sur le mainHolder.

Code: [ Select ]
MovieClip.prototype.preload = function(targClip) {
    this.onEnterFrame = function() {
        this.bLoaded = targClip.getBytesLoaded();
        this.bTotal = targClip.getBytesTotal();
        if (this.bLoaded == this.bTotal && targClip._width>0) {
            delete this.onEnterFrame;
            //do whatever you want when image is loaded
        }
    };
};
  1. MovieClip.prototype.preload = function(targClip) {
  2.     this.onEnterFrame = function() {
  3.         this.bLoaded = targClip.getBytesLoaded();
  4.         this.bTotal = targClip.getBytesTotal();
  5.         if (this.bLoaded == this.bTotal && targClip._width>0) {
  6.             delete this.onEnterFrame;
  7.             //do whatever you want when image is loaded
  8.         }
  9.     };
  10. };


Et vous êtes code serait quelque chose comme ça ..

Code: [ Select ]
myMain = new XML();
myMain.ignoreWhite = true;
myMain.load("fashion.xml");
myMain.onLoad = function(success) {
    numimages = this.firstChild.childNodes.length;
    _global.imagenum = numimages;
    spacing = 465;
    for (i=0; i<numimages; i++) {
        pictHolder = this.firstChild.childNodes[i];
        mainHolder = loader.createEmptyMovieClip("loaders"+i, i);
        mainHolder._x = i*spacing;
        mainHolder.title = pictHolder.attributes.title;
        mainHolder.main = pictHolder.attributes.main;
        mainLoader = mainHolder.createEmptyMovieClip("main_image"+i, i);
        mainLoader.loadMovie(pictHolder.attributes.main);
        //added this line
        mainHolder.preload(mainLoader);
    }
};
  1. myMain = new XML();
  2. myMain.ignoreWhite = true;
  3. myMain.load("fashion.xml");
  4. myMain.onLoad = function(success) {
  5.     numimages = this.firstChild.childNodes.length;
  6.     _global.imagenum = numimages;
  7.     spacing = 465;
  8.     for (i=0; i<numimages; i++) {
  9.         pictHolder = this.firstChild.childNodes[i];
  10.         mainHolder = loader.createEmptyMovieClip("loaders"+i, i);
  11.         mainHolder._x = i*spacing;
  12.         mainHolder.title = pictHolder.attributes.title;
  13.         mainHolder.main = pictHolder.attributes.main;
  14.         mainLoader = mainHolder.createEmptyMovieClip("main_image"+i, i);
  15.         mainLoader.loadMovie(pictHolder.attributes.main);
  16.         //added this line
  17.         mainHolder.preload(mainLoader);
  18.     }
  19. };



Maintenant c'est une procédure standard...et je ne suis même sûr que ce sera vraiment le travail, car il dépend de la configuration et tout ce que le jazz, mais il devrait...si elle n'a rien de visible ne se passe (il faut ajouter que dans le prototype précharge).

Oh, et au cas où vous vous interrogez sur cette ligne
Code: [ Select ]
if (this.bLoaded == this.bTotal && targClip._width>0) {
et pourquoi il a targClip._width> 0...thats bien pour empêcher toute opération de chargement faux. Voir, si rien n'est chargé...de 0 octets chargé ne En effet égal à 0 octets au total...Alors, que si cette déclaration ne se vérifie si les octets chargés est égal au total d'octets et s'assure qu'il n'y est contenu réel au clip et son pas vide.
  • roarmeow
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Oct 12, 2004
  • Messages: 861
  • Loc: BKNY
  • Status: Offline

Message Mai 22nd, 2005, 8:48 pm

merci pour la rapidité des réponses à mes deux postes.

im va donner un coup demain.

bien tenus.

aussi, ive a un autre travail pour le moment, mais si vous voulez le vérifier juste pour me donner des indications sur la manière dont je peux améliorer mon actionscript, id certainement reconnaissant.

prendre soin de,
rondelle
  • lostinbeta
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Juin 26, 2003
  • Messages: 1402
  • Loc: Philadelphia, PA
  • Status: Offline

Message Mai 22nd, 2005, 9:09 pm

En autodidacte actionscripter, mon code n'est jamais vraiment propre. Oui, il est possible d'être autodidacte et propre, mais ma méthode d'autant que cela fonctionne semble fonctionner pour moi...Im pas que anale au sujet de mon code. Ainsi, techniquement, je ne suis vraiment pas celui d'aller pour obtenir des conseils sur la façon de nettoyer ou d'améliorer le code. Je connais quelques trucs et astuces ici et là, mais rien d'extraordinaire.

Mais si je mai faire un ajustement du code dans les postes précédents...et ce serait d'utiliser l'argument succès de la onLoad. «réussite» est un argument passé en tant que vrai lorsque le contenu est effectivement chargée. Son un peu intelligent "debug" checker Flash possède. Pour l'utiliser vous devez avoir une instruction if dans votre onLoad.
Code: [ Select ]
myMain = new XML();
myMain.ignoreWhite = true;
myMain.load("fashion.xml");
myMain.onLoad = function(success) {
    if (success) {
        numimages = this.firstChild.childNodes.length;
        _global.imagenum = numimages;
        spacing = 465;
        for (i=0; i<numimages; i++) {
            pictHolder = this.firstChild.childNodes[i];
            mainHolder = loader.createEmptyMovieClip("loaders"+i, i);
            mainHolder._x = i*spacing;
            mainHolder.title = pictHolder.attributes.title;
            mainHolder.main = pictHolder.attributes.main;
            mainLoader = mainHolder.createEmptyMovieClip("main_image"+i, i);
            mainLoader.loadMovie(pictHolder.attributes.main);
            //added this line
            mainHolder.preload(mainLoader);
        }
    } else {
        trace("OH NO MY FILE DIDN'T LOAD!");
    }
};
  1. myMain = new XML();
  2. myMain.ignoreWhite = true;
  3. myMain.load("fashion.xml");
  4. myMain.onLoad = function(success) {
  5.     if (success) {
  6.         numimages = this.firstChild.childNodes.length;
  7.         _global.imagenum = numimages;
  8.         spacing = 465;
  9.         for (i=0; i<numimages; i++) {
  10.             pictHolder = this.firstChild.childNodes[i];
  11.             mainHolder = loader.createEmptyMovieClip("loaders"+i, i);
  12.             mainHolder._x = i*spacing;
  13.             mainHolder.title = pictHolder.attributes.title;
  14.             mainHolder.main = pictHolder.attributes.main;
  15.             mainLoader = mainHolder.createEmptyMovieClip("main_image"+i, i);
  16.             mainLoader.loadMovie(pictHolder.attributes.main);
  17.             //added this line
  18.             mainHolder.preload(mainLoader);
  19.         }
  20.     } else {
  21.         trace("OH NO MY FILE DIDN'T LOAD!");
  22.     }
  23. };
  • roarmeow
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Oct 12, 2004
  • Messages: 861
  • Loc: BKNY
  • Status: Offline

Message Mai 23rd, 2005, 5:43 pm

bien être mauvais, LIB (get it?)...

vous êtes un génie. que des merveilles...Maintenant, je peux mettre en place un centre de Preloader et les images, une fois chargé dans tous les theyre...good stuff.

aussi, j'apprécie beaucoup les conseils sur les meilleures pratiques. peut-être que vous ne vous sentez pas comme vous êtes au bon endroit pour donner des conférences sur l'avoir propre script, mais vous êtes certainement me pointer dans la bonne direction et i really appreciate it.

tous les meilleurs,
rondelle
  • jamesholden
  • Born
  • Born
  • No Avatar
  • Inscription: Oct 26, 2006
  • Messages: 1
  • Status: Offline

Message Octobre 26th, 2006, 8:04 am

Salut,

Im désireux de savoir comment je peux ajouter un preloader qui charge toutes les images à la fois ou que précharge chaque image individuellement à l'aide de ce code. Lors du chargement de préférence avec un symbole de pourcentage.

Code: [ Select ]
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.load("xmlphoto.xml");
myPhoto.onLoad = function(success) {
    //portfolioTag = this.firstChild;
    numimages = this.firstChild.childNodes.length;
    spacing = 70;
    for (i=0; i<numimages; i++) {
        this.picHolder = this.firstChild.childNodes[i];
        this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
        this.thumbHolder._x = i*spacing;
        this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
        this.thumbLoader.loadMovie(this.picHolder.attribut es.thmb);
        this.thumbHolder.title = this.picHolder.attributes.title;
        this.thumbHolder.main = this.picHolder.attributes.main;
        this.thumbHolder.onRelease = function() {
            loader.loadMovie(this.main);
            title_txt.text = this.title;
        };
    }
};
  1. myPhoto = new XML();
  2. myPhoto.ignoreWhite = true;
  3. myPhoto.load("xmlphoto.xml");
  4. myPhoto.onLoad = function(success) {
  5.     //portfolioTag = this.firstChild;
  6.     numimages = this.firstChild.childNodes.length;
  7.     spacing = 70;
  8.     for (i=0; i<numimages; i++) {
  9.         this.picHolder = this.firstChild.childNodes[i];
  10.         this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
  11.         this.thumbHolder._x = i*spacing;
  12.         this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
  13.         this.thumbLoader.loadMovie(this.picHolder.attribut es.thmb);
  14.         this.thumbHolder.title = this.picHolder.attributes.title;
  15.         this.thumbHolder.main = this.picHolder.attributes.main;
  16.         this.thumbHolder.onRelease = function() {
  17.             loader.loadMovie(this.main);
  18.             title_txt.text = this.title;
  19.         };
  20.     }
  21. };


Merci à l'avance.

JH.
  • IceCold
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Nov 05, 2004
  • Messages: 1254
  • Loc: Ro
  • Status: Offline

Message Octobre 27th, 2006, 12:11 am

id utiliser la précontrainte individuelles pour chaque image.
pour cela vous devez d'abord précharge pour chaque pouce, puis Preloader pour les images de taille normale.
Youll avoir à utiliser
this.onEnterFrame = function ()
(
if (ThumbsLoaded ())
(
delete onEnterFrame;
gotoAndPlay (nextFrame);
)
)

dans ThumbsLoaded () vous devez vérifier que chaque clip vidéo est en chargement, individuellement, et si tous chargés return true.
mais trop paresseux im maintenant à écrire le code. peut-être une autre fois.
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”
  • pisosse
  • Born
  • Born
  • No Avatar
  • Inscription: Fév 19, 2008
  • Messages: 1
  • Status: Offline

Message Février 19th, 2008, 11:53 am

HEY iceCold...j'aime beaucoup cette idée .. mais comment vous arrivez à ce sujet?

cela pourrait-il vierge après vous convaincre de faire un exemple?

Afficher de l'information

  • Total des messages de ce sujet: 8 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 41 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC