Package | away3d.loading.parsers |
Class | public class ParserBase |
Inheritance | ParserBase flash.events.EventDispatcher |
Subclasses | AC3DParser, AWD1Parser, AWD2Parser, ColladaParser, ImageParser, Max3DSParser, MD2Parser, MD5AnimParser, MD5MeshParser, OBJParser |
ParserBase
provides an abstract base class for objects that convert blocks of data to data structures
supported by Away3D.
If used by AssetLoader
to automatically determine the parser type, two static public methods should
be implemented, with the following signatures:
public static function supportsType(extension : String) : Boolean
Indicates whether or not a given file extension is supported by the parser.
public static function supportsData(data : : Boolean
Tests whether a data block can be parsed by the parser.
Furthermore, for any concrete subtype, the method initHandle
should be overridden to immediately
create the object that will contain the parsed data. This allows ResourceManager
to return an object
handle regardless of whether the object was loaded or not.
See also
Property | Defined by | ||
---|---|---|---|
baseUri : String [read-only]
The parent url of the file to be parsed.
| ParserBase | ||
dataFormat : String [read-only]
The data format of the file data to be parsed.
| ParserBase | ||
defaultBitmapData : BitmapData [read-only]
The url or id of the data or file to be parsed.
| ParserBase | ||
dependencies : Vector [read-only]
A list of dependencies that need to be loaded and resolved for the object being parsed.
| ParserBase | ||
eventVerbosity : int
The threshold that define which events are dispatched.
| ParserBase | ||
handle : IResource
[read-only]
The object that will contain all the parsed data.
| ParserBase | ||
parsingFailure : Boolean | ParserBase | ||
uri : String [read-only]
The url or id of the data or file to be parsed.
| ParserBase |
Property | Defined by | ||
---|---|---|---|
_byteData : ByteArray | ParserBase | ||
_dataFormat : String | ParserBase | ||
_dependencies : Vector
A list of dependencies that need to be loaded and resolved for the object being parsed.
| ParserBase | ||
_frameLimit : Number | ParserBase | ||
_lastFrameTime : Number | ParserBase | ||
_textData : String | ParserBase |
Method | Defined by | ||
---|---|---|---|
ParserBase
(uri:String, format:String)
Creates a new ParserBase object
| ParserBase | ||
isBitmapDataValid(bitmapData:BitmapData):Boolean
Validates a bitmapData loaded before assigning to a default BitmapMaterial
| ParserBase | ||
parseBytesAsync(bytes:ByteArray, frameLimit:Number = 30):void
Parse byte array (possibly containing plain text) asynchronously, meaning that
the parser will periodically stop parsing so that the AVM may proceed to the
next frame.
| ParserBase | ||
parseTextAsync(str:String, frameLimit:Number = 30):void
Parse plaintext string asynchronously, meaning that the parser will periodically
stop parsing so that the AVM may proceed to the next frame.
| ParserBase |
Method | Defined by | ||
---|---|---|---|
finishParsing():void
Finish parsing the data.
| ParserBase | ||
hasTime():Boolean
Tests whether or not there is still time left for parsing within the maximum allowed time frame per session.
| ParserBase | ||
Creates the object that will be returned to the user and will contain all the loaded data.
| ParserBase | ||
onInterval(event:TimerEvent = null):void
Called when the parsing pause interval has passed and parsing can proceed.
| ParserBase | ||
proceedParsing():Boolean
Parse the next block of data.
| ParserBase |
Constant | Defined by | ||
---|---|---|---|
MORE_TO_PARSE : Boolean = false [static]
Returned by
proceedParsing to indicate more parsing is needed, allowing asynchronous parsing. | ParserBase | ||
PARSING_DONE : Boolean = true [static]
Returned by
proceedParsing to indicate no more parsing is needed. | ParserBase |
baseUri | property |
baseUri:String
[read-only]The parent url of the file to be parsed.
Implementation public function get baseUri():String
_byteData | property |
protected var _byteData:ByteArray
_dataFormat | property |
protected var _dataFormat:String
dataFormat | property |
dataFormat:String
[read-only]
The data format of the file data to be parsed. Can be either ParserDataFormat.BINARY
or ParserDataFormat.PLAIN_TEXT
.
public function get dataFormat():String
defaultBitmapData | property |
defaultBitmapData:BitmapData
[read-only]The url or id of the data or file to be parsed.
Implementation public function get defaultBitmapData():BitmapData
_dependencies | property |
protected var _dependencies:Vector
A list of dependencies that need to be loaded and resolved for the object being parsed.
See also
dependencies | property |
dependencies:Vector
[read-only]A list of dependencies that need to be loaded and resolved for the object being parsed.
Implementation public function get dependencies():Vector
eventVerbosity | property |
eventVerbosity:int
[read-write]The threshold that define which events are dispatched.
Implementation public function get eventVerbosity():int
public function set eventVerbosity(value:int):void
_frameLimit | property |
protected var _frameLimit:Number
handle | property |
handle:IResource
[read-only]The object that will contain all the parsed data.
Implementation public function get handle():IResource
_lastFrameTime | property |
protected var _lastFrameTime:Number
parsingFailure | property |
parsingFailure:Boolean
[read-write]Implementation
public function get parsingFailure():Boolean
public function set parsingFailure(value:Boolean):void
_textData | property |
protected var _textData:String
uri | property |
uri:String
[read-only]The url or id of the data or file to be parsed.
Implementation public function get uri():String
ParserBase | () | constructor |
public function ParserBase(uri:String, format:String)
Parameters
uri:String — The url or id of the data or file to be parsed.
|
|
format:String — The data format of the file data to be parsed. Can be either ParserDataFormat.BINARY or ParserDataFormat.PLAIN_TEXT , and should be provided by the concrete subtype.
|
See also
finishParsing | () | method |
protected function finishParsing():void
Finish parsing the data.
hasTime | () | method |
protected function hasTime():Boolean
Tests whether or not there is still time left for parsing within the maximum allowed time frame per session.
ReturnsBoolean — True if there is still time left, false if the maximum allotted time was exceeded and parsing should be interrupted.
|
initHandle | () | method |
protected function initHandle():IResource
Creates the object that will be returned to the user and will contain all the loaded data. This allows
ResourceManager
to return an object handle regardless of whether the object was loaded or not,
which in turn allows users to add objects to the scene or assign materials before they are actually loaded.
This method needs to be overridden by concrete subclasses.
IResource —
A reference to the handle.
|
isBitmapDataValid | () | method |
public function isBitmapDataValid(bitmapData:BitmapData):Boolean
Validates a bitmapData loaded before assigning to a default BitmapMaterial
ParametersbitmapData:BitmapData |
Boolean |
onInterval | () | method |
protected function onInterval(event:TimerEvent = null):void
Called when the parsing pause interval has passed and parsing can proceed.
Parametersevent:TimerEvent (default = null )
|
parseBytesAsync | () | method |
public function parseBytesAsync(bytes:ByteArray, frameLimit:Number = 30):void
Parse byte array (possibly containing plain text) asynchronously, meaning that the parser will periodically stop parsing so that the AVM may proceed to the next frame.
Parametersbytes:ByteArray — The byte array in which the loaded data resides.
|
|
frameLimit:Number (default = 30 ) — number of milliseconds of parsing allowed per frame. The
actual time spent on a frame can exceed this number since time-checks can
only be performed between logical sections of the parsing procedure.
|
parseTextAsync | () | method |
public function parseTextAsync(str:String, frameLimit:Number = 30):void
Parse plaintext string asynchronously, meaning that the parser will periodically stop parsing so that the AVM may proceed to the next frame. If this parser requires binary data, an error will be thrown.
Parametersstr:String — Text data used for parsing.
|
|
frameLimit:Number (default = 30 ) — number of milliseconds of parsing allowed per frame. The
actual time spent on a frame can exceed this number since time-checks can
only be performed between logical sections of the parsing procedure.
|
proceedParsing | () | method |
protected function proceedParsing():Boolean
Parse the next block of data.
ReturnsBoolean — Whether or not more data needs to be parsed. Can be ParserBase.PARSING_DONE or
ParserBase.MORE_TO_PARSE .
|
resolveDependency | () | method |
arcane function resolveDependency(resourceDependency:ResourceDependency):void
Resolve a dependency when it's loaded. For example, a dependency containing an ImageResource would be assigned to a Mesh instance as a BitmapMaterial, a scene graph object would be added to its intended parent. The dependency should be a member of the dependencies property.
ParametersresourceDependency:ResourceDependency — The dependency to be resolved.
|
resolveDependencyFailure | () | method |
arcane function resolveDependencyFailure(resourceDependency:ResourceDependency):void
Resolve a dependency loading failure. Used by parser to eventually provide a default map
ParametersresourceDependency:ResourceDependency — The dependency to be resolved.
|
MORE_TO_PARSE | constant |
protected static const MORE_TO_PARSE:Boolean = false
Returned by proceedParsing
to indicate more parsing is needed, allowing asynchronous parsing.
PARSING_DONE | constant |
protected static const PARSING_DONE:Boolean = true
Returned by proceedParsing
to indicate no more parsing is needed.