Barre de progression dans galerie photo (LoadMovie)

subonoiz Messages postés 3 Date d'inscription jeudi 28 août 2003 Statut Membre Dernière intervention 5 février 2004 - 2 févr. 2004 à 11:59
GillesWebmaster Messages postés 496 Date d'inscription mercredi 30 juin 2004 Statut Membre Dernière intervention 29 juillet 2009 - 31 déc. 2007 à 16:36
S'lt @ tous!
Chui débutant en flash et action script et je voudrais savoir comment pour mettre une barre de chargement dans ma galerie....
Mon annim se compose d'une seul image avec un conteneur ('photos.square.cl_image') et le code suivant (que j'ai récupéré et adapté):


_global.ville="Mexico";
var site;
getURL(site);
site="http://viajeamexico.free.fr/";
_global.dir = site+_global.ville+"/Images/";

loadVariables(dir+"texte.txt", this);

comentPhoto._alpha=70;
whichPic=1;
_root.input=1;
photos._xscale = 30;
photos._yscale = 30;
z = 30;
photos.square._x = -880;
photos.square._y = -1340;
photos._x=398;
photos._y=412;
photos.square._alpha = 0;
_root.onEnterFrame = function() {
photovar=eval("txt"+whichPic);
photos.square.onPress = function() {
photos.square.startDrag();
};
photos.square.onRelease = function() {
photos.square.stopDrag();
};
if (photos.square._alpha>10 && fadeOut) {
photos.square._alpha -= 20;
}

if (photos.square._alpha<10) {
loadMovie(dir+"image"+whichPic+".JPG", "photos.square.cl_image");
_root.sortie.text = "";
_root.coment.textColor = 0xFF0000;
fadeOut = false;
fadeIn = true;
}
if (photos.square._alpha<100 && fadeIn && !fadeOut) {
photos.square._alpha += 20;
} else {
fadeIn = false;
}
if (photos.square.cl_image._width>=photos.square.cl_image._height) {
if (photos.square.cl_image._width>1000) {
photos.square.cl_image._width = photos.square.cl_image._width/1.03;
photos.square.cl_image._height = photos.square.cl_image._height/1.03;
}
if (photos.square.cl_image._width>100 && photos.square.cl_image._width<980) {
photos.square.cl_image._width = photos.square.cl_image._width*1.03;
photos.square.cl_image._height = photos.square.cl_image._height*1.03;
}
} else {
if (photos.square.cl_image._height>760) {
photos.square.cl_image._width = photos.square.cl_image._width/1.03;
photos.square.cl_image._height = photos.square.cl_image._height/1.03;
}
if (photos.square.cl_image._height>100 && photos.square.cl_image._height<740) {
photos.square.cl_image._width = photos.square.cl_image._width*1.03;
photos.square.cl_image._height = photos.square.cl_image._height*1.03;
}
}
};


Bon ça marche mais je ne vois comment faire pour y integrer une barre de chargement ...
Voila!!
Merci d'avance!

3 réponses

cs_Helmer Messages postés 132 Date d'inscription mardi 14 octobre 2003 Statut Membre Dernière intervention 2 décembre 2004 2
4 févr. 2004 à 11:14
Salut,

Il faut que tu crées sur la scène un clip avec comme nom d'occurrence " barre " : alors après tu la conçois comme tu veux ta barre de chargement proprement dite ...

( L'exemple type c'est celui-ci : sur la première image du fait un rectangle aligné à droite du point d'origne, d'une faible largeur ( exemple 1 pixel ) ; et à l'image 100 refais ce même rectangle mais avec une largeur importante ( exemple 100 pixel .. ) .. Ensuite fais une interpolation de forme entre ces 2 images ... )

Nota Bene : Autrement, faisons simple et mets l'occurence de ce clip là où tu veux qu'elle apparaisse lors d'un chargement, sachant qu'on va la rendre visible si il y a lieu d'un chargement, et invisible s'il n'y a aucunes données à charger ...

Reviens sur la scène, et sur la première image , ou du moins là où ça va s'avérer nécessaire :

barre._visible=false

Remplaces ça :

<>

Par ça :

if (photos.square._alpha<10) {
loadMovie(dir+"image"+whichPic+".JPG", "photos.square.cl_image");
_root.sortie.text = "";
_root.coment.textColor = 0xFF0000;
_root.barre._visible=true;
var totales = _root.photos.square.cl_image.getBytesTotal();
var chargées = _root.photos.square.cl_image.getBytesLoaded();
var rapport =Math.ceil((chargées/totales)*100);
_root.barre.gotoAndPlay(rapport);
if(rapport==100){
fadeOut = false;
fadeIn = true;
_root.barre._visible = false;
}
}

Ouai je pense que ça doit marcher ...
+
0
subonoiz Messages postés 3 Date d'inscription jeudi 28 août 2003 Statut Membre Dernière intervention 5 février 2004
5 févr. 2004 à 18:08
Merci!!!!
ça marche nickel!!!
:big)
@+!
0
GillesWebmaster Messages postés 496 Date d'inscription mercredi 30 juin 2004 Statut Membre Dernière intervention 29 juillet 2009 1
31 déc. 2007 à 16:36
Bonjour ,

J'ai le même problème mais je charge une vingtaine d'images et j'aimerai leur affecter une barre de progression INDIVIDUELLE.

MovieClip.prototype.chargement_jpg = function(jpg, couleur, larg, haut,descript) {
    var cible = this.dest;
    cible._alpha = 0;
    cible.loadMovie(jpg);
    var id = setInterval(function (mc) {
        var d = mc["dest"];
        progression=d.getBytesLoaded() / d.getBytesTotal()
        if ((progression<1))
            {
                //QUE METTRE ICI?
            }
        else
            {
                if (d._width > 0) {
                    clearInterval(id);
                    d.memw = d._width;
                    d.memh = d._height;
                    d.proportion = (d._width / d._height);
                    d._width = Math.floor(mc._w0 * 2);
                    d._height = Math.floor(mc._h0 * 2);
                    d._alpha = 99;
                    with (d) {
                        lineStyle(2, 0x000000, 80);
                        moveTo(this._x + memw + 1, this._y - 1);
                        lineTo(this._x + memw + 1, this._y + memh + 1);
                        lineTo(this._x - 1, this._y + memh + 1);
                        lineStyle(1, 0x000000, 80);
                        lineTo(this._x - 1, this._y - 1);
                        lineTo(this._x + memw + 1, this._y - 1);
                    }
                    // --------------------
                    mc._alpha = 99;
                    mc._width = mc._w0* 1.55;
                    mc._height = mc._h0 * 1.55;
                    mc.onPress = cliquer;
                } else {
                    var pourcent = (d.getBytesLoaded() / d.getBytesTotal());
                    mc._width = pourcent * mc._w0 * 1.5;
                    mc._height = pourcent * mc._h0 * 1.5;
                }
            }
    }, 100, this);
};

Bonne Journée
0
Rejoignez-nous