Packageaway3d.loading.parsers
Classpublic class ParserBase
InheritanceParserBase Inheritance flash.events.EventDispatcher
SubclassesAC3DParser, 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

away3d.loading.parsers.AssetLoader
away3d.loading.ResourceManager
Public Properties
 PropertyDefined 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
Protected Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
Protected Methods
 MethodDefined 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
Protected Constants
 ConstantDefined 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
Property detail
baseUriproperty
baseUri:String  [read-only]

The parent url of the file to be parsed.

Implementation
    public function get baseUri():String
_byteDataproperty 
protected var _byteData:ByteArray
_dataFormatproperty 
protected var _dataFormat:String
dataFormatproperty 
dataFormat:String  [read-only]

The data format of the file data to be parsed. Can be either ParserDataFormat.BINARY or ParserDataFormat.PLAIN_TEXT.

Implementation
    public function get dataFormat():String
defaultBitmapDataproperty 
defaultBitmapData:BitmapData  [read-only]

The url or id of the data or file to be parsed.

Implementation
    public function get defaultBitmapData():BitmapData
_dependenciesproperty 
protected var _dependencies:Vector

A list of dependencies that need to be loaded and resolved for the object being parsed.

See also

dependenciesproperty 
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
eventVerbosityproperty 
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
_frameLimitproperty 
protected var _frameLimit:Number
handleproperty 
handle:IResource  [read-only]

The object that will contain all the parsed data.

Implementation
    public function get handle():IResource
_lastFrameTimeproperty 
protected var _lastFrameTime:Number
parsingFailureproperty 
parsingFailure:Boolean  [read-write]Implementation
    public function get parsingFailure():Boolean
    public function set parsingFailure(value:Boolean):void
_textDataproperty 
protected var _textData:String
uriproperty 
uri:String  [read-only]

The url or id of the data or file to be parsed.

Implementation
    public function get uri():String
Constructor detail
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.
Init Parameters

See also

Method detail
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.

Returns
Boolean — 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.

Returns
IResource — A reference to the handle.
isBitmapDataValid()method 
public function isBitmapDataValid(bitmapData:BitmapData):Boolean

Validates a bitmapData loaded before assigning to a default BitmapMaterial

Parameters
bitmapData:BitmapData

Returns
Boolean
onInterval()method 
protected function onInterval(event:TimerEvent = null):void

Called when the parsing pause interval has passed and parsing can proceed.

Parameters
event: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.

Parameters
bytes: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.

Parameters
str: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.

Returns
Boolean — 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.

Parameters
resourceDependency: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

Parameters
resourceDependency:ResourceDependency — The dependency to be resolved.
Constant detail
MORE_TO_PARSEconstant
protected static const MORE_TO_PARSE:Boolean = false

Returned by proceedParsing to indicate more parsing is needed, allowing asynchronous parsing.

PARSING_DONEconstant 
protected static const PARSING_DONE:Boolean = true

Returned by proceedParsing to indicate no more parsing is needed.

Wiki link
Click to go to the wiki page for 'away3d.loading.parsers.ParserBase'

Code examples

Comments