03.07.2013 Views

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

■ Les nombres ou les valeurs booléennes sont considérés comme égaux lorsque leur valeur<br />

est i<strong>de</strong>ntique.<br />

■ Les expressions <strong>de</strong> type String sont égales lorsqu'elles comportent le même nombre <strong>de</strong><br />

caractères et que ces caractères sont i<strong>de</strong>ntiques.<br />

■ Les variables représentant <strong>de</strong>s objets, <strong>de</strong>s tableaux et <strong>de</strong>s fonctions sont comparées par<br />

référence. Deux variables sont égales lorsqu'elles font référence au même objet, au même<br />

tableau ou à la même fonction. Deux tableaux distincts ne sont jamais considérés comme<br />

égaux, même s'ils comportent le même nombre d'éléments.<br />

Disponibilité : Flash Player 6 ; <strong>ActionScript</strong> 1.0<br />

Opéran<strong>de</strong>s<br />

expression1 : Object - Nombre, chaîne, valeur booléenne, variable, objet, tableau ou<br />

fonction.<br />

expression2 : Object - Nombre, chaîne, valeur booléenne, variable, objet, tableau ou<br />

fonction.<br />

Valeur renvoyée<br />

Boolean - Résultat booléen <strong>de</strong> la comparaison.<br />

Exemple<br />

Les commentaires inclus dans le co<strong>de</strong> suivant affichent la valeur renvoyée <strong>de</strong>s opérations qui<br />

utilisent les opérateurs d'égalité et d'égalité stricte :<br />

// Both return true because no conversion is done<br />

var string1:String = "5";<br />

var string2:String = "5";<br />

trace(string1 == string2); // true<br />

trace(string1 === string2); // true<br />

// Automatic data typing in this example converts 5 to "5"<br />

var string1:String = "5";<br />

var num:Number = 5;<br />

trace(string1 == num); // true<br />

trace(string1 === num); // false<br />

// Automatic data typing in this example converts true to "1"<br />

var string1:String = "1";<br />

var bool1:Boolean = true;<br />

trace(string1 == bool1); // true<br />

trace(string1 === bool1); // false<br />

// Automatic data typing in this example converts false to "0"<br />

var string1:String = "0";<br />

var bool2:Boolean = false;<br />

trace(string1 == bool2); // true<br />

trace(string1 === bool2); // false<br />

190 Chapitre 1: Eléments <strong>du</strong> <strong>langage</strong> <strong>ActionScript</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!