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.

this[name] = f;<br />

// return the <strong>reference</strong> to the function<br />

return f;<br />

};<br />

// test __resolve using un<strong>de</strong>fined method names with parameters<br />

myObject.someMethod("hello");<br />

// output: Method someMethod was called with arguments: hello<br />

myObject.someOtherMethod("hello","world");<br />

// output: Method someOtherMethod was called with arguments: hello,world<br />

Voir également<br />

arguments, Array<br />

toString (métho<strong>de</strong> Object.toString)<br />

public toString() : String<br />

Convertit l'objet spécifié en chaîne et renvoie cette <strong>de</strong>rnière.<br />

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

Valeur renvoyée<br />

String - Chaîne.<br />

Exemple<br />

Cet exemple affiche la valeur renvoyée pour toString() sur un objet générique :<br />

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

trace(myObject.toString()); // output: [object Object]<br />

Cette métho<strong>de</strong> peut être remplacée pour renvoyer une valeur plus significative. Les exemples<br />

suivants indiquent que cette métho<strong>de</strong> a été remplacée pour les classes intégrées Date, Array et<br />

Number :<br />

// Date.toString() returns the current date and time<br />

var myDate:Date = new Date();<br />

trace(myDate.toString()); // output: [current date and time]<br />

// Array.toString() returns the array contents as a comma-<strong>de</strong>limited string<br />

var myArray:Array = new Array("one", "two");<br />

trace(myArray.toString()); // output: one,two<br />

// Number.toString() returns the number value as a string<br />

// Because trace() won't tell us whether the value is a string or number<br />

// we will also use typeof() to test whether toString() works.<br />

var myNumber:Number = 5;<br />

Object 1039

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

Saved successfully!

Ooh no, something went wrong!