Bonjour, je vais bientôt créer un trombinoscope et j'ai un problème dans mon code.
Le script charge des photos avec un loadmovie lorsqu'on clique sur un bouton.
Une photo que les photos sont chargés, j'aimerai que lorsqu'on clique sur un photo, la function test s'exécute. Mais elle ne le fait pas.
On a beau relire le script et faire diverse manipulation on ne comprend pas ce qui cloche dans le script.
Aidez moi s'il vous plait

.
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| var MyScale:Number = 10;// Mise a l'échelle des photos
var MyNbCol:Number = 10;// Nombre de photos sur chaque ligne
var MyPhotoOffset:Number = 70;
//=> Pour mouvement
var gX:Number = 2;
var gY:Number = 2;
var gPhotoCount:Number = 0;
monXml = new XML();
monXml.ignoreWhite = true;
monXml.load("witien.xml");
function test() {
ClearPhotos();
};
function BuildPhotos(thePays:String)
{
var MyRow:Number = 0;
var MyCol:Number = 0;
var MyIdent:Number = 0;
for (var MyWitien:XMLNode = monXml.firstChild.firstChild; MyWitien != null; MyWitien = MyWitien.nextSibling)
{
if ((thePays == MyWitien.attributes.pays) or (thePays == ""))
{
//=> Créer un objet pour la photo
this.createEmptyMovieClip("Photo_" + MyIdent,this.getNextHighestDepth());
//=> Charge la photo
var MyPhotoObj = eval("Photo_" + MyIdent);
MyPhotoObj.loadMovie("photos/" + MyWitien.attributes.prenom + "." + MyWitien.attributes.nom + ".jpg");
//=> Calcul de la position de la photo
MyRow = int(MyIdent / MyNbCol);
MyCol = (MyIdent % MyNbCol);
MyPhotoObj._x = (MyCol * MyPhotoOffset) + 30;
MyPhotoObj._y = (MyRow * MyPhotoOffset) + 30;
MyPhotoObj._xscale = 2;
MyPhotoObj._yscale = 2;
MyPhotoObj.onPress= function() {
Test();
}
//=> Incrémente le numéro de photo
MyIdent = MyIdent + 1;
}
}
gPhotoCount=MyIdent;
}
function ClearPhotos()
{
for (MyIdent:Number=0;MyIdent<gPhotoCount;MyIdent=MyIdent+1)
{
removeMovieClip("Photo_" + MyIdent);
}
}
tous_btn.onPress = function()
{
ClearPhotos();
BuildPhotos("");
play();
};
FR_btn.onPress = function()
{
ClearPhotos();
BuildPhotos("FR");
play();
};
IT_btn.onPress = function()
{
ClearPhotos();
BuildPhotos("IT");
play();
};
ES_btn.onPress = function()
{
ClearPhotos();
BuildPhotos("ES");
play();
};
//====== onEnterFrame > répete action à la cadence de l'animation
_root.onEnterFrame = function()
{
for (MyIdent:Number=0;MyIdent<gPhotoCount;(MyIdent=MyIdent+1))
{
var MyPhotoObj = eval("Photo_" + MyIdent);
if (MyPhotoObj._xscale <= 10) {
MyPhotoObj._xscale = MyPhotoObj._xscale + 1;
MyPhotoObj._yscale = MyPhotoObj._yscale + 1;
}
}
};
Photo_2.onMouseDown = test(); |