Package | flash.errors |
Class | public dynamic class EOFError |
Inheritance | EOFError IOError Error Object |
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.0 |
See also
Public Properties
Public Methods
Method | Defined By | ||
---|---|---|---|
Creates a new EOFError object. | EOFError | ||
Returns the call stack for an error as a string at the time of the error's construction (for the debugger version
of Flash Player and the AIR Debug Launcher (ADL) only; returns null if not using the debugger version
of Flash Player or the ADL. | Error | ||
Indicates whether an object has a specified property defined. | Object | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
[override]
Returns the string "Error" by default or the value contained in the Error.message property,
if defined. | Error | ||
Returns the primitive value of the specified object. | Object |
Constructor Detail
EOFError | () | Constructor |
public function EOFError(message:String = "")
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0 Flash Player 9 |
Creates a new EOFError object.
Parametersmessage:String (default = " ") — A string associated with the error object.
|
Examples ( How to use this example )
EOFErrorExample.as
The following example uses the
EOFErrorExample
class to show
the error generated if an attempt is made to read past the end of the available
data. This is accomplished with the following steps:
- The constructor creates a ByteArray object
byteArr
and writes a Boolean value offalse
into the byte stream usingwriteBoolean()
. - The position of
byteArr
is reset to0
(start of the data stream). - A single byte is removed from the data stream using
readBoolean()
. The data stream now contains no data. - Within an error handling code segment set to catch EOFError objects,
readBoolean()
is called a second time and the EOFError is caught and passed to atrace()
statement, which outputs the error message associated with EOFError objects.
package { import flash.display.Sprite; import flash.errors.EOFError; import flash.utils.ByteArray; public class EOFErrorExample extends Sprite { public function EOFErrorExample() { var byteArr:ByteArray = new ByteArray(); byteArr.writeBoolean(false); trace(byteArr.length); // 1 byteArr.position = 0; try { trace(byteArr.readBoolean()); // false } catch(e:EOFError) { trace(e); } try { trace(byteArr.readBoolean()); } catch(e:EOFError) { trace(e); // EOFError: Error #2030: End of file was encountered. } } } }
Fri Mar 19 2010, 02:45 AM -07:00