Chrgement .xml aléatoire... COMMENT FAIRE ????

nicmet12 Messages postés 4 Date d'inscription dimanche 15 février 2009 Statut Membre Dernière intervention 14 mars 2011 - 15 févr. 2009 à 14:31
nicmet12 Messages postés 4 Date d'inscription dimanche 15 février 2009 Statut Membre Dernière intervention 14 mars 2011 - 16 févr. 2009 à 18:51
Bonjour,

J’aimerais qu’au chargement de la page, le fichier .XML soit appelé de manière aléatoire.

Ce qu’il y a dans mon fichier Flash :

//load XM data
//set default xmlPath
var xmlPath = "gallery.xml"
//get xml data Path from flashVars
if (_root.xmlDataPath != undefined){
    xmlPath = _root.xmlDataPath;
}
_global.gImageData_xml = new XML();
gImageData_xml.onLoad = xmlLoaded;
gImageData_xml.ignoreWhite = true;
gImageData_xml.load(xmlPath);
function xmlLoaded(success){
    mcLoader.onEnterFrame = undefined;
    if (success){                
        mcLoader.setLoadBarWidth(1);
        gotoAndPlay("done");                                    }else{
        trace("Load XML failed");
        mcLoader.gotoAndStop(2);
    }    
}
stop();

Et dans la page HTML :

    }
</style>

</head>

    

SimpleViewer requires JavaScript and the Flash Player. Get Flash.

<script type="text/javascript">

var fo = new SWFObject("viewer.swf", "viewer", "100%", "100%", "8", "#000000");

// SIMPLEVIEWER CONFIGURATION OPTIONS
        
// To use an option, uncomment it by removing the "//" at the start of the line
    
// For a description of config options, go to:
        
// http://www.airtightinteractive.com/simpleviewer/options.html
        
        //fo.addVariable("xmlDataPath", "gallery.xml");
        //fo.addVariable("firstImageIndex", "5");    
        //fo.addVariable("langOpenImage", "Open Image in New Window");
        //fo.addVariable("langAbout", "About");    
        //fo.addVariable("preloaderColor", "0xFFFFFF");
        
        fo.write("flashcontent");    
    
</script>    

</html>

J’ai essyé, mais sans succès d’appliquer ce bout de code ……

var xml = new Array(“gallery1.xml”, “gallery2.xml”, “gallery3.xml”,“gallery4.xml”, “gallery5.xml”,“gallery6.xml”,“gallery.xml”;
 var rnd = Math.round(Math.random()(xml.length-1));
 xml.load = xml(xml[rnd])

Si vous avez une solution,

MERCI
A voir également:

5 réponses

ChasseurDeChimeres Messages postés 292 Date d'inscription mercredi 7 novembre 2007 Statut Membre Dernière intervention 15 janvier 2013 3
15 févr. 2009 à 23:30
 Slt;
je sais pas si tu recopier ce code tel que car il y a quelques erreurs, mais le raisonnement est tout à fait logique.
d'abord il manque une parenthèse et ensuite tu execute une fonction "load" sur un array qui, je pense, ne possède pas cette propriété et pour être tatillon, il manque un ";" à la fin^^.

var xml = new Array("gallery1.xml", "gallery2.xml", "gallery3.xml","gallery4.xml", "gallery5.xml", "gallery6.xml",  

   "gallery.xml"
)

;


 var rnd = Math.round(Math.random()(xml.length-1));

gImageData_xml.load
= xml(xml[rnd]);

en espérant que cela te soit utile, ++.
0
nicmet12 Messages postés 4 Date d'inscription dimanche 15 février 2009 Statut Membre Dernière intervention 14 mars 2011
16 févr. 2009 à 08:39
MERCI !!! Je vais de ce pas tester ça !!! C'est bien juste.... je colle ce bout de code corrigé dans la page FLASH !!! J'avais un peut tout essayé, mais avec ces fautes, c'est sur ca ne pouvait pas marcher...
Je donne des news si ça a marché !!! Pour l'instant... je prie

Merci encore a+

Nico
0
nicmet12 Messages postés 4 Date d'inscription dimanche 15 février 2009 Statut Membre Dernière intervention 14 mars 2011
16 févr. 2009 à 10:37
Bon, ben voilà ça ne marche pas... Whattodowhattodowhattodo ????? MERCI de me secourir, je vais finir par bouter le feu à l'ordi !!!!

a bientôt
0
ChasseurDeChimeres Messages postés 292 Date d'inscription mercredi 7 novembre 2007 Statut Membre Dernière intervention 15 janvier 2013 3
16 févr. 2009 à 12:22
   salut;
Soit plus précis, donne nous les erreurs et même si tu peu les fichiers source.
  cordialement.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
nicmet12 Messages postés 4 Date d'inscription dimanche 15 février 2009 Statut Membre Dernière intervention 14 mars 2011
16 févr. 2009 à 18:51
YAHOOOOO SUPER !!!!

Il suffisait de se rendre sur le forum d'AIRTIGHT, et j'ai trouvé un solution encore plus simple !!!

Modify your HTML code as follows (add the bold instructions):


<script type= "text/javascript">

var randomnumber=Math.floor(Math. random ()*10);

var fo = new SWFObject("ext/viewer.swf", "viewer", "700", "700", "7", "#F1F2F3");

fo.addVariable("firstImageIndex", randomnumber);

fo.addVariable("preloaderColor", "0xffffff");


fo.addVariable("xmlDataPath", "gallery.xml");


fo.addVariable("fontColor", "0x919191");


fo.addVariable("footer", "");


fo.write("flashcontent");


</script><script type="text/javascript" language="javascript">


In this example I had 9 pictures to display, if you have got mor or less, change Math.random()*n);


N being one more than the number of images.

Ca marche super bien !

MERCI encore !

bonne semaine

Nico
0
Rejoignez-nous