Gizmil
Messages postés709Date d'inscriptionmercredi 14 avril 2004StatutMembreDernière intervention 3 octobre 2022
-
18 févr. 2006 à 15:07
cs_dto
Messages postés70Date d'inscriptiondimanche 7 septembre 2003StatutMembreDernière intervention20 septembre 2006
-
18 févr. 2006 à 16:47
Salut à tous,
J'ai un petit problème, j'aimerais savoir comment faire passer des paramètres à une fonction. Le problème, c'est que l'aide de Flash ne méclaire pas vraiment (un peu trop abstrait comme explications).
Voici un code que j'aimerais simplifier dans son écriture parce que là, c'est pas très lisible. il parait que placer ma variable visNbr en paramètre pourrait m'aider: function nomDeFonction(visNbr); mais qu'est-ce que je dois faire ensuite, à l'intérieur de la fonction?
Le code:
//fonction d'identification de la vis survolée
vis01_mc.onRollOver = function() {
visNbr = 1;
};
vis02_mc.onRollOver = function() {
visNbr = 2;
};
vis03_mc.onRollOver = function() {
visNbr = 3;
};
vis04_mc.onRollOver = function() {
visNbr = 4;
};
//--------------------------------
//fonctions de dévissage et d'arrêt de dévissage
this["devisserVis0"+visNbr] = function () {
trace("fonction devisserVis ok");
this["vis0"+visNbr+"_mc"].onPress = function() {
trace("vis pressee ok");
this.play();
this.visQuiTourne_mc.play();
};
this["vis0"+visNbr+"_mc"].onRelease = function() {
this.stop();
this.visQuiTourne_mc.stop();
};
this["vis0"+visNbr+"_mc"].onReleaseOutside = function() {
this.stop();
this.visQuiTourne_mc.stop();
};
};
//------------------------------------------
//Fonctions permettant le revissage d'une vis
this["revisserVis0"+visNbr] = function () {
this["vis0"+visNbr+"_mc"].onPress = function() {
trace("revissage prêt");
this.play();
this.visQuiTourne_mc.play();
};
this["vis0"+visNbr+"_mc"].onRelease = function() {
this.stop;
this.visQuiTourne_mc.stop();
};
this["vis0"+visNbr+"_mc"].onReleaseOutside = function() {
this.stop;
this.visQuiTourne_mc.stop();
};
};
//Fonctions intervenant quand le dévissage est terminé
//magnetismeV0xZ0x centre la vis sur un trou de vis
this["magnetismeV0"+visNbr+"Z01"] = function () {
this["vis0"+visNbr+"_mc"]._x = 123;
this["vis0"+visNbr+"_mc"]._y = 239;
};
this["magnetismeV0"+visNbr+"Z02"] = function () {
this["vis0"+visNbr+"_mc"]._x = 886;
this["vis0"+visNbr+"_mc"]._y = 239;
};
this["magnetismeV0"+visNbr+"Z03"] = function () {
this["vis0"+visNbr+"_mc"]._x = 123;
this["vis0"+visNbr+"_mc"]._y = 604;
};
this["magnetismeV0"+visNbr+"Z04"] = function () {
this["vis0"+visNbr+"_mc"]._x = 886;
this["vis0"+visNbr+"_mc"]._y = 604;
};
//---------------------------
//dragNdrop permet de bouger la vis et enclenche le magnetisme si la vis est près d'un trou de vis
this["dragNdropVis0"+visNbr] = function () {
this["vis0"+visNbr+"_mc"].onPress = function() {
this.startDrag(false);
};
this["vis0"+visNbr+"_mc"].onRelease = function() {
if (this["vis0"+visNbr+"_mc"].hitTest(zoneVis01_mc)) {
raMain["magnetismeV0"+visNbr+"Z01()"];
this.stopDrag();
} else if (this["vis0"+visNbr+"_mc"].hitTest(zoneVis02_mc)) {
raMain["magnetismeV0"+visNbr+"Z02()"];
this.stopDrag();
} else if (this["vis0"+visNbr+"_mc"].hitTest(zoneVis03_mc)) {
raMain["magnetismeV0"+visNbr+"Z03()"];
this.stopDrag();
} else if (this["vis0"+visNbr+"_mc"].hitTest(zoneVis04_mc)) {
raMain["magnetismeV0"+visNbr+"Z04()"];
this.stopDrag();
} else {
this.stopDrag();
}
};
};