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 crée un objet générique appelé myObject :<br />

var myObject:Object = new Object();<br />

__proto__ (Object.__proto__ property)<br />

public __proto__ : Object<br />

Fait référence à la propriété prototype <strong>de</strong> la classe (<strong>ActionScript</strong> <strong>2.0</strong>) ou <strong>de</strong> la fonction<br />

constructeur (<strong>ActionScript</strong> 1.0) utilisée pour créer l'objet. La propriété __proto__ est<br />

automatiquement affectée à tous les objets au moment <strong>de</strong> leur création. L'interpréteur<br />

d'<strong>ActionScript</strong> utilise la propriété __proto__ pour accé<strong>de</strong>r à la propriété prototype <strong>de</strong> la<br />

classe <strong>de</strong> l'objet ou <strong>de</strong> la fonction constructeur afin <strong>de</strong> rechercher les propriétés et les<br />

métho<strong>de</strong>s héritées par l'objet <strong>de</strong> sa superclasse.<br />

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

Exemple<br />

L'exemple suivant crée une classe appelée Shape, ainsi qu'une sous-classe <strong>de</strong> Shape appelée<br />

Circle.<br />

// Shape class <strong>de</strong>fined in external file named Shape.as<br />

class Shape {<br />

function Shape() {}<br />

}<br />

// Circle class <strong>de</strong>fined in external file named Circle.as<br />

class Circle extends Shape{<br />

function Circle() {}<br />

}<br />

La classe Circle permet <strong>de</strong> créer <strong>de</strong>ux instances <strong>de</strong> Circle :<br />

var oneCircle:Circle = new Circle();<br />

var twoCircle:Circle = new Circle();<br />

Les instructions <strong>de</strong> suivi ci-<strong>de</strong>ssous indiquent que la propriété __proto_ <strong>de</strong>s <strong>de</strong>ux<br />

occurrences se rapporte à la propriété prototype <strong>de</strong> la classe Circle.<br />

trace(Circle.prototype == oneCircle.__proto__); // Output: true<br />

trace(Circle.prototype == twoCircle.__proto__); // Output: true<br />

Voir également<br />

prototype (Object.prototype, propriété)<br />

Object 1033

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

Saved successfully!

Ooh no, something went wrong!