Package | flash.errors |
Class | public dynamic class EOFError |
Inheritance | EOFError IOError Error Object |
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
More examples
Working with the debugger versions
of Flash runtimes
Comparing the Error classes
flash.error package Error classes
Comparing the Error classes
flash.error package Error classes
Related API Elements
Public Properties
Public Methods
Method | Defined By | ||
---|---|---|---|
Creates a new EOFError object. | EOFError | ||
Returns the call stack for an error at the time of the error's
construction as a string. | 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 |
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. } } } }
Thu Dec 6 2018, 01:12 PM -08:00