IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

rotation d'images


Sujet :

JavaScript

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 46
    Points : 17
    Points
    17
    Par défaut rotation d'images
    hello
    voila je suis en train de faire un script pour faire tourner 7 series d'images au dessus de 7 menus deroulants, les images doivent tourner toutes seules et surtout sont predefinies et sans lien attaché mais je coince
    exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    <script language="JavaScript">
    var tabimg = new Array();//declaration d'un tableau 
    var actuel = new Array();//declaration de la variable actuel pour savoir où l'on en est
    actuel=Array(1,1,1,1,1,1,1);//On initialise actuel
    tabimg[1]=Array(); //tableau 1
    (tabimg[1][1]=new Image()).src="imagecomzanzibar24.jpg"; 
    (tabimg[1][2]=new Image()).src="imagecompsoudan85.jpg";
    tabimg[2]=Array(); //tableau 2
    (tabimg[1][3]=new Image()).src="imagecommexique49.jpg";
    (tabimg[1][3]=new Image()).src="imagecompquateur80.jpg";
    (tabimg[1][3]=new Image()).src="imagecomguatemala4.jpg";
    tabimg[3]=Array(); //tableau 3
    (tabimg[1][3]=new Image()).src="imagecompyemen5.jpg";
    (tabimg[1][3]=new Image()).src="photoscominde206.jpg";
    (tabimg[1][3]=new Image()).src="photoscompouzbek19.jpg";
    tabimg[4]=Array(); //tableau 4
    (tabimg[1][1]=new Image()).src="photoscompbulgarie34.jpg";
    tabimg[5]=Array(); //tableau 5
    (tabimg[5][5]=new Image()).src="imagecompceylan118.jpg";
    (tabimg[5][5]=new Image()).src="imagecompgalap5.jpg";
    (tabimg[5][5]=new Image()).src="imagecomzanzibar47.jpg";
    (tabimg[5][5]=new Image()).src="photoscompislande35.jpg";
    (tabimg[5][5]=new Image()).src="imagecompguad11.jpg";
    tabimg[6]=Array(); //tableau 6
    (tabimg[6][3]=new Image()).src="imagecompvillest11.jpg";
    (tabimg[6][3]=new Image()).src="imagecompvenise34.jpg";
    (tabimg[6][3]=new Image()).src="imagecompistamboul.jpg";
    tabimg[7]=Array(); //tableau 7
    (tabimg[7][5]=new Image()).src="photoscompennons14.jpg";
    (tabimg[7][5]=new Image()).src="imagecompgalap5.jpg";
    (tabimg[7][5]=new Image()).src="imagecomzanzibar47.jpg";
    (tabimg[7][5]=new Image()).src="photoscompislande35.jpg";
    (tabimg[7][5]=new Image()).src="imagecompguad11.jpg";
    function rotation(){//rotation 
    }
    var i;//variable de rotation 
    for(i=1;i<tabimg.length;i++){
    }
    eval("new Image"+i+".src=tabimg["+i+"]["+actuel[i]+ "].src;");
    actuel[i]=actuel[i]+1;
    if(actuel[i]>=tabimg[i].length){
    actuel[i]=1;
    }
    setTimeout("rotation();", 1000);//definition du temps d'attente
    rotation();//On lance pour la première fois la rotation.
    //-->
    </script>
    voila mais ca marche pas !!!!! dans eval new image est pas reconnu
    et dans le header je met quoi ?
    si quelqu'un a une idee, je suis preneur
    merci d'avance
    amicalement
    philippe du web

  2. #2
    Expert éminent

    Avatar de denisC
    Profil pro
    Développeur Java
    Inscrit en
    Février 2005
    Messages
    4 050
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Service public

    Informations forums :
    Inscription : Février 2005
    Messages : 4 050
    Points : 7 641
    Points
    7 641
    Par défaut
    Citation Envoyé par philippe du web
    voila mais ca marche pas !!!!! dans eval new image est pas reconnu
    et dans le header je met quoi ?
    Qu'est ce qu'il est sensé faire le eval???
    De quel header tu parles?

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 46
    Points : 17
    Points
    17
    Par défaut rotation d'images
    hello
    alors eval sert a situer la rotation et a l'incrementer
    pas le header plutot le body dans le header il y a les scripts

  4. #4
    Expert éminent

    Avatar de denisC
    Profil pro
    Développeur Java
    Inscrit en
    Février 2005
    Messages
    4 050
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Service public

    Informations forums :
    Inscription : Février 2005
    Messages : 4 050
    Points : 7 641
    Points
    7 641
    Par défaut
    Citation Envoyé par philippe du web
    hello
    alors eval sert a situer la rotation et a l'incrementer
    pas le header plutot le body dans le header il y a les scripts
    Désolé, , mais je ne comprends vraiment pas. Si tu veux changer une image sur ta page, tu n'as pas besoin d'eval....

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 46
    Points : 17
    Points
    17
    Par défaut rotation d'images
    hello
    alors mon script sert a faire une rotation d'images mais a 7 endroit differents et surtout que cela se fasse automatiquement sans passer la souris dessus ou autre chose
    amicalement
    philippe du web

  6. #6
    Expert éminent

    Avatar de denisC
    Profil pro
    Développeur Java
    Inscrit en
    Février 2005
    Messages
    4 050
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Service public

    Informations forums :
    Inscription : Février 2005
    Messages : 4 050
    Points : 7 641
    Points
    7 641
    Par défaut
    Citation Envoyé par philippe du web
    alors mon script sert a faire une rotation d'images mais a 7 endroit differents et surtout que cela se fasse automatiquement sans passer la souris dessus ou autre chose
    On est bien d'accord. Tu geres les effets de bord et tout.

    Mais c'est simplement la ligne avec l'eval que je ne comprends pas. C'est celle qui est sensé changer l'image dans la page?

    Un petit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    document.getElementById('imagequitourne'+i).src = tabimg[i][actuel[i]].src
    Ca te va pas? Pourquoi faire un eval???

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 46
    Points : 17
    Points
    17
    Par défaut rotation d'images
    hello
    eval sert a faire la boucle et aussi a evaluer ou j'en suis dans le bouche via la variable actuel voila

  8. #8
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 46
    Points : 17
    Points
    17
    Par défaut rotation des images
    hello
    mais dans ce que tu me propose document et image qui tourne ne sont pas definit comme variable faut il que je le fasse ou pas ?
    amicalement
    philippe du web

  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 46
    Points : 17
    Points
    17
    Par défaut rotation d'images
    hello
    quand je le teste dans mon script il me dit que la valeur est nulle et n'est pas un objet !!!!
    amicalement
    philippe du web

  10. #10
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 46
    Points : 17
    Points
    17
    Par défaut
    Voila j'ai changé deux trois trucs dont la définition de la fonction mais cela ne marche toujours pas.



    <script language="JavaScript">

    var tabimg = new Array();//declaration d'un tableau
    var actuel = new Array();//declaration de la variable actuel pour savoir où l'on en est
    var i;//variable de rotation

    actuel=new Array(1,1,1,1,1,1,1);//On initialise actuel

    tabimg[0]=new Array(); //tableau 1
    (tabimg[0][1]=new Image()).src="imagecomzanzibar24.jpg";
    (tabimg[0][2]=new Image()).src="imagecompsoudan85.jpg";

    tabimg[1]=new Array(); //tableau 2
    (tabimg[1][1]=new Image()).src="imagecommexique49.jpg";
    (tabimg[1][2]=new Image()).src="imagecompquateur80.jpg";
    (tabimg[1][3]=new Image()).src="imagecomguatemala4.jpg";

    tabimg[2]=new Array(); //tableau 3
    (tabimg[2][1]=new Image()).src="imagecompyemen5.jpg";
    (tabimg[2][2]=new Image()).src="photoscominde206.jpg";
    (tabimg[2][3]=new Image()).src="photoscompouzbek19.jpg";

    tabimg[3]=new Array(); //tableau 4
    (tabimg[3][1]=new Image()).src="photoscompbulgarie34.jpg";

    tabimg[4]=new Array(); //tableau 5
    (tabimg[4][1]=new Image()).src="imagecompceylan118.jpg";
    (tabimg[4][2]=new Image()).src="imagecompgalap5.jpg";
    (tabimg[4][3]=new Image()).src="imagecomzanzibar47.jpg";
    (tabimg[4][4]=new Image()).src="photoscompislande35.jpg";
    (tabimg[4][5]=new Image()).src="imagecompguad11.jpg";

    tabimg[5]=new Array(); //tableau 6
    (tabimg[5][1]=new Image()).src="imagecompvillest11.jpg";
    (tabimg[5][2]=new Image()).src="imagecompvenise34.jpg";
    (tabimg[5][3]=new Image()).src="imagecompistamboul.jpg";

    tabimg[6]=new Array(); //tableau 7
    (tabimg[6][1]=new Image()).src="photoscompennons14.jpg";
    (tabimg[6][2]=new Image()).src="imagecompgalap5.jpg";
    (tabimg[6][3]=new Image()).src="imagecomzanzibar47.jpg";
    (tabimg[6][4]=new Image()).src="photoscompislande35.jpg";
    (tabimg[6][5]=new Image()).src="imagecompguad11.jpg";

    document.getElementById('imagequitourne'+i).src = tabimg[i][actuel[i]].src


    for(i=0;i<tabimg.lenght;i++){
    }


    if(i+1>=tabimg[i].length){
    actuel[i]=0;
    }else{
    actuel[i]=actuel[i]+1;
    }

    setTimeout("rotation();", 1000);//definition du temps d'attente

    //-->
    </script>

Discussions similaires

  1. Rotation d'images par semaine
    Par Invité dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 28/11/2006, 18h13
  2. Rotation d'image dans un état
    Par Papapetch dans le forum IHM
    Réponses: 3
    Dernier message: 10/06/2006, 18h02
  3. Rotation d'image (matrice)
    Par AsmBoy dans le forum Algorithmes et structures de données
    Réponses: 1
    Dernier message: 16/01/2006, 07h49
  4. Faire une rotation d'image
    Par sozie9372 dans le forum 2D
    Réponses: 6
    Dernier message: 30/11/2005, 22h40
  5. [Image]Rotation d'image
    Par psychomatt dans le forum 2D
    Réponses: 6
    Dernier message: 16/12/2004, 20h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo