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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Exemple<br />

L'exemple suivant décrit l'utilisation <strong>de</strong> l'opérateur NOT (-) au niveau <strong>du</strong> bit avec les bits<br />

indicateurs :<br />

var ReadOnlyFlag:Number = 0x0001; // <strong>de</strong>fines bit 0 as the read-only flag<br />

var flags:Number = 0;<br />

trace(flags);<br />

/* To set the read-only flag in the flags variable,<br />

the following co<strong>de</strong> uses the bitwise OR:<br />

*/<br />

flags |= ReadOnlyFlag;<br />

trace(flags);<br />

/* To clear the read-only flag in the flags variable,<br />

first construct a mask by using bitwise NOT on ReadOnlyFlag.<br />

In the mask, every bit is a 1 except for the read-only flag.<br />

Then, use bitwise AND with the mask to clear the read-only flag.<br />

The following co<strong>de</strong> constructs the mask and performs the bitwise AND:<br />

*/<br />

flags &= ~ReadOnlyFlag;<br />

trace(flags);<br />

// output: 0 1 0<br />

Voir également<br />

& Opérateur AND au niveau <strong>du</strong> bit, &= Opérateur d'affectation AND au niveau <strong>du</strong><br />

bit, Opérateur ^ (XOR au niveau <strong>du</strong> bit), Opérateur ^= (affectation XOR au<br />

niveau <strong>du</strong> bit), | Opérateur OR au niveau <strong>du</strong> bit, |= Opérateur d'affectation OR<br />

au niveau <strong>du</strong> bit<br />

| Opérateur OR au niveau <strong>du</strong> bit<br />

expression1 | expression2<br />

Convertit expression1 et expression2 en entiers 32 bits non signés et renvoie un 1 pour<br />

chaque position <strong>de</strong> bit où les bits correspondants <strong>de</strong> expression1 ou expression2 ont la<br />

valeur 1. Les nombres à virgule flottante sont convertis en entiers en supprimant tous les<br />

chiffres situés après la virgule. Le résultat est un nouvel entier <strong>de</strong> 32 bits.<br />

Les entiers positifs sont convertis en valeur hexadécimale non signée dont la valeur maximale<br />

est <strong>de</strong> 4294967295 ou 0xFFFFFFFF. Les valeurs supérieures au maximum per<strong>de</strong>nt leurs<br />

chiffres les plus importants lorsqu'elles sont converties, <strong>de</strong> façon à ce que la valeur <strong>de</strong>meure à<br />

32 bits. Les nombres négatifs sont convertis en valeur hexadécimale non signée par<br />

l'intermédiaire <strong>de</strong> la notation complément à <strong>de</strong>ux, la valeur minimale étant <strong>de</strong> -2147483648<br />

ou 0x800000000. Les nombres inférieurs à cette valeur minimale sont convertis en<br />

complément à <strong>de</strong>ux avec une plus gran<strong>de</strong> précision et per<strong>de</strong>nt leurs chiffres les plus<br />

importants.<br />

Opérateurs 149

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

Saved successfully!

Ooh no, something went wrong!