03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

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 reference to the function<br />

return f;<br />

};<br />

// test __resolve using undefined 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 />

See also<br />

arguments, Array<br />

toString (Object.toString method)<br />

public toString() : String<br />

Converts the specified object to a string <strong>and</strong> returns it.<br />

Returns<br />

String - A string.<br />

Example<br />

This example shows the return value for toString() on a generic object:<br />

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

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

This method can be overridden to return a more meaningful value. The following examples<br />

show that this method has been overridden for the built-in classes Date, Array, <strong>and</strong> Number:<br />

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

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

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

// Array.toString() returns the array contents as a comma-delimited 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 />

trace(typeof (myNumber)); // output: number<br />

trace(myNumber.toString()); // output: 5<br />

trace(typeof (myNumber.toString())); // output: string<br />

532 ActionScript classes

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

Saved successfully!

Ooh no, something went wrong!