J'aimerai faire une fonction avec un argument ???

Martino26 Messages postés 55 Date d'inscription vendredi 11 avril 2003 Statut Membre Dernière intervention 24 février 2006 - 6 mai 2003 à 16:32
Martino26 Messages postés 55 Date d'inscription vendredi 11 avril 2003 Statut Membre Dernière intervention 24 février 2006 - 6 mai 2003 à 21:20
Bonjour je fait un site web avec des images et des zoom sur les images et je veut faire des fonction avec des argument pour qu il soit plus facile d ajouter des images plustard et optimiser mon code en meme temps

ex pour le zoom

//code actuel sans fonction pour 2 photos
on (press) {
if ((compteur == 1) && (img1._height < 339)) {
img1._height = img1._height * 1.5;
img1._width = img1._width * 1.5;
cadrephoto._height = img1._height + 40;
cadrephoto._width = img1._width + 40;
}
if ((compteur == 2) && (img2._height < 339)) {
img2._height = img2._height * 1.5;
img2._width = img2._width * 1.5;
cadrephoto._height = img2._height + 40;
cadrephoto._width = img2._width + 40;
}

}

Je voudrait avoir un style de fonction

//code voulu pour plusieur photo a la fois :P
function.zoom(valeur) {
if (img + valeur + ._height < 339) {
img + valeur + ._height = img + valeur + ._height * 1.5;
img + valeur + ._width = img + valeur + ._width * 1.5;
cadrephoto._height = img + valeur + ._height + 40;
cadrephoto._width = img + valeur + ._width + 40;
}

}

et apres faire mon action de bouton avec

on (press) {
valeur = compteur;
zoom(valeur);
}

SVP si quelqu un sait si c'est possible repondez moi :)

7 réponses

cs_tombal Messages postés 212 Date d'inscription samedi 8 février 2003 Statut Membre Dernière intervention 25 juillet 2005
6 mai 2003 à 18:55
Bon vu que tu sais ce qu'il faut faire, je te donne la syntaxe

Pour une fonction :
function nom_de_fonction (parametre) {
//code
}

Pour l'histoire du img1, img2...
_root["img"+x]._height = valeur

exemple :
function zoom (x,aggrandissement) {
_root.["img"+x].height = _root.["img"+x].height*aggrandissement;
//Tu fais praeil avec le reste
}

//pour zoomer l'image 3 d'un facteur 2
zoom (3,2);

Tombal
0
Martino26 Messages postés 55 Date d'inscription vendredi 11 avril 2003 Statut Membre Dernière intervention 24 février 2006
6 mai 2003 à 19:55
Merci tu ma bien compris a ce que je voit j ai tester et je ny arrive pas. Avec l aide quej ai trouver dans le dictionnaire action script je voit bien que tu as raison Mais j ai tj des erreur quand je compile

j ai pourtant fait ma fonction comme tu me la montrer
c'est peut-etre que je ne sait pas ou mettre ma fonction
la c'est dans la meme séquence et dans la scene 1
la scene de mon fond de mon site

function zoom(x) {
_root.["img"+x].height = _root.["img"+x].height * 1.5;
_root.["img"+x].width = _root.["img"+x].width * 1.5;
cadrephoto._height = _root.["img"+x].height + 40;
cadrephoto._width = _root.["img"+x].width + 40;
}

jai ses 4 erreur la une pour chaque ligneSéquence site, Calque FOND, Image = 1 : Ligne 44 : Un nom de champ est attendu après l’opérateur '.'.
_root.["img"+x].height = _root.["img"+x].height * 1.5;

(meme erreur pour les 4 lignes)

et la fonction elle est declancher par un bouton avec
on (press) {
zoom(compteur);
}

compteur etant le numero de l image

Je fait plein de test en attendant ta reponse :)
0
cs_tombal Messages postés 212 Date d'inscription samedi 8 février 2003 Statut Membre Dernière intervention 25 juillet 2005
6 mai 2003 à 20:58
LOL tu a oublié des _ dans _height
enfin c'est plutot moi qui les ais oublié ;)

function zoom(x) {
_root.["img"+x]._height = _root.["img"+x]._height * 1.5;
_root.["img"+x]._width = _root.["img"+x]._width * 1.5;
cadrephoto._height = _root.["img"+x]._height + 40;
cadrephoto._width = _root.["img"+x]._width + 40;
}

Tombal
0
cs_tombal Messages postés 212 Date d'inscription samedi 8 février 2003 Statut Membre Dernière intervention 25 juillet 2005
6 mai 2003 à 21:00
Autre chose que j'ai pas vu, tu a mis de spoint la ou j'en ai pas mis =)
entre le _root et les crochet, il ne faut pas de point

function zoom(x) {
_root["img"+x]._height = _root["img"+x]._height * 1.5;
_root["img"+x]._width = _root.["img"+x]._width * 1.5;
cadrephoto._height = _root["img"+x]._height + 40;
cadrephoto._width = _root["img"+x]._width + 40;
}

Tombal
0

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

Posez votre question
cs_tombal Messages postés 212 Date d'inscription samedi 8 février 2003 Statut Membre Dernière intervention 25 juillet 2005
6 mai 2003 à 21:03
ROOOOOO
Je suis fatigué aujourd'hui, excuse moi.......
(c le stress des exam)
C moi qui ais mis des point partout et oublier des trucs

Bon voici le bon code
function zoom(x) {
_root["img"+x]._height = _root["img"+x]._height * 1.5;
_root["img"+x]._width = _root["img"+x]._width * 1.5;
cadrephoto._height = _root["img"+x]._height + 40;
cadrephoto._width = _root["img"+x]._width + 40;
}

Tombal
0
Martino26 Messages postés 55 Date d'inscription vendredi 11 avril 2003 Statut Membre Dernière intervention 24 février 2006
6 mai 2003 à 21:04
Au moment ou tu ma repondu je venait d allumer cette erreur
aussi lol
mais j ai toujour cette erreur c comme si il voit pas img + x
j ai donc essayer aussi avec _root.img[x]._height mais rien de plus j allume vraiment pas :P
Séquence site, Calque FOND, Image = 1 : Ligne 44 : Un nom de champ est attendu après l'opérateur '.'.
> _root.["img"+x].height = _root.["img"+x]._height * 1.5;
0
Martino26 Messages postés 55 Date d'inscription vendredi 11 avril 2003 Statut Membre Dernière intervention 24 février 2006
6 mai 2003 à 21:20
Parfait ca !!
merci bien mec je t en doit une :)
tanks pour ta patience
besoin de quoi que se soit je suis sur mirc undernet sur #irc-jeux pseudo Martino26 @+
0
Rejoignez-nous