These methods are grouped
based on the starting type of the data to convert, though the naming conventions don ??™ t help in making
them particularly distinguishable.
Functions contained in classes are termed methods . This term will be used to describe functions of
classes throughout the rest of this book.
Table 3 - 2 lists the available conversion methods.
Table 3 - 2
Std Method Description
bool( val : Dynamic ) : Bool Converts any value to a boolean type. Only 0
(zero), null, and false are returned as false .
string( val : Dynamic ) : String Converts any value to a string.
chr( val : Int ) : String Converts ASCII code to a string.
ord( val : String ) : Int Converts the first letter of a given string to its
equivalent ASCII code.
int( val : Float ) : Int Rounds a float down and returns as an integer.
parseFloat( val : String ) : Float Converts a string to a float.
parseInt( val : String ) : Int Converts a string to an integer.
When using any of the conversion methods listed in the previous table, you must precede the method
call with the Std class name using dot notation, as each of the methods are static and belong to the Std
class.
Pages:
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113