Définir une apparition aléatoire selon certaines coordonées

mx_lover Messages postés 10 Date d'inscription mardi 25 mai 2004 Statut Membre Dernière intervention 9 janvier 2010 - 26 mai 2004 à 19:08
mx_lover Messages postés 10 Date d'inscription mardi 25 mai 2004 Statut Membre Dernière intervention 9 janvier 2010 - 27 mai 2004 à 19:15
bonjour,

voila le code suivant définit l'apparition aléatoire d'un clip en abscise sur 590 pixels, et ça marche très bien...

if (_root.cible_present == 0) {
_root.cible_present = 1;
setProperty("_root.cible", _x, random (590));
tellTarget ("_root.cible") {
play();
}
}

Maintenant, j'aimerais établir l'apparition de ce clip aléatoirement, mais parmi un nombre de postion en x définies seulement.

par exemple que le clip apparîtrait soit à 30, 400, ou 200 d'abscisse et uniqument ces coordonées la.

Quel serait donc le code à ce moment la ?

une idée ? :)

6 réponses

Prouprou_Sensei Messages postés 517 Date d'inscription mardi 23 décembre 2003 Statut Membre Dernière intervention 24 octobre 2006 1
26 mai 2004 à 19:52
crée un tableau :
mon_array = new Array(30, 200, 400);
remet ceci:
if (_root.cible_present == 0) {
_root.cible_present = 1;
root.cible._x = mon_array[random(mon_array.length)];
root.cible.play();
}
tu aura une valeur parmit celles de ton tableau prise au hasard.
A tchao !
0
mx_lover Messages postés 10 Date d'inscription mardi 25 mai 2004 Statut Membre Dernière intervention 9 janvier 2010
26 mai 2004 à 20:25
je vais essayer ça, merci à toi
0
SuperDevy Messages postés 842 Date d'inscription dimanche 24 novembre 2002 Statut Membre Dernière intervention 2 juillet 2007
26 mai 2004 à 20:28
Si tu veux les mettre régulièrement :

ecart = 50
if (_root.cible_present == 0) {
_root.cible_present = 1;
_root.cible._x = Math.round(random()/ecart*590)*ecart;
_root.cible.play();
}
0
mx_lover Messages postés 10 Date d'inscription mardi 25 mai 2004 Statut Membre Dernière intervention 9 janvier 2010
27 mai 2004 à 14:47
Re, j'ai essayé le code suivant :

mon_array = new Array(30, 200, 400);
if (_root.cible_present == 0) {
_root.cible_present = 1;
root.cible._x = mon_array[random(mon_array.length)];
root.cible.play();
}

Mais du coup mon clip ne s'affiche plus; lors de la lecture séquence...

Que faire ??? :question)
0

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

Posez votre question
Prouprou_Sensei Messages postés 517 Date d'inscription mardi 23 décembre 2003 Statut Membre Dernière intervention 24 octobre 2006 1
27 mai 2004 à 17:04
C pas normal effectivement mais ca viens sans doute du fait que tu n'as pas mis de _ avant root sur la ligne du _x. c'est de ma faute... je l'avai pas mis dans l'exemple.
Essay donc avec _root.cible._x = mon_array[random(mon_array.length)];
0
mx_lover Messages postés 10 Date d'inscription mardi 25 mai 2004 Statut Membre Dernière intervention 9 janvier 2010
27 mai 2004 à 19:15
Voila, la solution était proche, quelqu'un d'autre m'a répondu sur un autre forum, voici le code pour ceux que ça intéresserait au passage...

avec Array ( tableau )

x = new Array();
x = ["50","150","250"];
if (_root.cible_present == 0) {
_root.cible_present = 1;
_root.cible._x = x[random (3)];
_root.cible.play();
}

On sait faire sans Array également

if (_root.cible_present == 0) {
_root.cible_present = 1;
_root.cible._x = 50+100*(random (3));
_root.cible.play();
}

[;-)]
0
Rejoignez-nous