Forum de discussion
Forum « Flash et Shockwave » (archives)
Re: detection valeur variable ds un champs texte
Envoyé: 17 mars 2006, 12h08 par dada
actuellement à la recherche de Paix éternelle, je vais tenter de répondre ;)
Déjà, j'ai pensé au onChanged aussi; mais voilà (j'espère que tu comprends l'anglais), extrait de la doc de onCHanged de flash :
-----------------------------------
The onChanged handler is called only when the change results from user interaction; for example, when the user is typing something on the keyboard, changing something in the text field using the mouse, or selecting a menu item. Programmatic changes to the text field do not trigger the onChanged event because the code recognizes changes that are made to the text field.
-------------------------------------
Par contre, on peut faire çà avec la classe Object et la méthode watch. Je me suis pas foulé, j'ai recopié l'exemple de l'aide, j'espère quand même que je mérite la Paix éternelle o.0 :p
-------------------------------------
// Create a new object
var myObject:Object = new Object();
// Add a property that tracks speed
myObject.speed = 0;
// Write the callback function to be executed if the speed property changes
var speedWatcher:Function = function(prop, oldVal, newVal, speedLimit) {
// Check whether speed is above the limit
if (newVal > speedLimit) {
trace ("You are speeding.");
}
else {
trace ("You are not speeding.");
}
// Return the value of newVal.
return newVal;
}
// Use watch() to register the event handler, passing as parameters:
// - the name of the property to watch: "speed"
// - a reference to the callback function speedWatcher
// - the speedLimit of 55 as the userData parameter
myObject.watch("speed", speedWatcher, 55);
// set the speed property to 54, then to 57
myObject.speed = 54; // output: You are not speeding
myObject.speed = 57; // output: You are speeding
// unwatch the object
myObject.unwatch("speed");
myObject.speed = 54; // there should be no output
----------------------------------------
++ :-)
dada
Réponses
|