Packageaway3d.loaders.parsers
Classpublic class ParserBase
InheritanceParserBase Inheritance flash.events.EventDispatcher
Subclasses AC3DParser, AWD1Parser, AWD2Parser, AWDParser, DAEParser, 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
  dataFormat : String
[read-only] The data format of the file data to be parsed.
ParserBase
  dependencies : Vector.<ResourceDependency>
[read-only] A list of dependencies that need to be loaded and resolved for the object being parsed.
ParserBase
  parsingComplete : Boolean
[read-only]
ParserBase
  parsingFailure : Boolean
ParserBase
  parsingPaused : Boolean
[read-only]
ParserBase
Protected Properties
 PropertyDefined By
  _data : *
ParserBase
  _dataFormat : String
ParserBase
  _frameLimit : Number
ParserBase
  _lastFrameTime : Number
ParserBase
Public Methods
 MethodDefined By
  
ParserBase(format:String)
Creates a new ParserBase object
ParserBase
  
isBitmapDataValid(bitmapData:BitmapData):Boolean
Validates a bitmapData loaded before assigning to a default BitmapMaterial
ParserBase
  
parseAsync(data:*, frameLimit:Number = 30):void
Parse data (possibly containing bytearry, plain text or BitmapAsset) asynchronously, meaning that the parser will periodically stop parsing so that the AVM may proceed to the next frame.
ParserBase
Protected Methods
 MethodDefined By
  
addDependency(id:String, req:URLRequest, retrieveAsRawData:Boolean = false, data:* = null, suppressErrorEvents:Boolean = false):void
ParserBase
  
constructSubGeometries(verts:Vector.<Number>, indices:Vector.<uint>, uvs:Vector.<Number>, normals:Vector.<Number>, tangents:Vector.<Number>, weights:Vector.<Number>, jointIndices:Vector.<Number>):Vector.<SubGeometry>
Build a list of sub-geometries from raw data vectors, splitting them up in such a way that they won't exceed buffer length limits.
ParserBase
  
constructSubGeometry(verts:Vector.<Number>, indices:Vector.<uint>, uvs:Vector.<Number>, normals:Vector.<Number>, tangents:Vector.<Number>, weights:Vector.<Number>, jointIndices:Vector.<Number>):SubGeometry
Build a sub-geometry from data vectors.
ParserBase
  
dieWithError(message:String = Unknown parsing error):void
ParserBase
  
finalizeAsset(asset:IAsset, name:String = null):void
ParserBase
  
Finish parsing the data.
ParserBase
  
getByteData():ByteArray
ParserBase
  
getTextData():String
ParserBase
  
hasTime():Boolean
Tests whether or not there is still time left for parsing within the maximum allowed time frame per session.
ParserBase
  
onInterval(event:TimerEvent = null):void
Called when the parsing pause interval has passed and parsing can proceed.
ParserBase
  
ParserBase
  
proceedParsing():Boolean
Parse the next block of data.
ParserBase
Events
 Event Summary Defined By
  Dispatched when an animation node has been constructed from a resource.ParserBase
  Dispatched when an animation set has been constructed from a group of animation state resources.ParserBase
  Dispatched when an animation state has been constructed from a group of animation node resources.ParserBase
  Dispatched when a animator asset has been constructed from a resource.ParserBase
  Dispatched when any asset finishes parsing.ParserBase
  Dispatched when a container asset has been constructed from a resource.ParserBase
  Dispatched when a geometry asset has been constructed from a resource.ParserBase
  Dispatched when a material asset has been constructed from a resource.ParserBase
  Dispatched when the parsing finishes.ParserBase
  Dispatched if an error was caught during parsing.ParserBase
  Dispatched when parser pauses to wait for dependencies, used internally to trigger loading of dependencies which are then returned to the parser through it's interface in the arcane namespace.ParserBase
  Dispatched when a skeleton asset has been constructed from a resource.ParserBase
  Dispatched when a skeleton pose asset has been constructed from a resource.ParserBase
  Dispatched when an animation state transition has been constructed from a group of animation node resources.ParserBase
  Dispatched when a texture asset has been constructed from a resource.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
_dataproperty
protected var _data:*

_dataFormatproperty 
protected var _dataFormat:String

_fileNameproperty 
arcane var _fileName:String

_frameLimitproperty 
protected var _frameLimit:Number

_lastFrameTimeproperty 
protected var _lastFrameTime:Number

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
dependenciesproperty 
dependencies:Vector.<ResourceDependency>  [read-only]

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


Implementation
    public function get dependencies():Vector.<ResourceDependency>
parsingCompleteproperty 
parsingComplete:Boolean  [read-only]


Implementation
    public function get parsingComplete():Boolean
parsingFailureproperty 
parsingFailure:Boolean


Implementation
    public function get parsingFailure():Boolean
    public function set parsingFailure(value:Boolean):void
parsingPausedproperty 
parsingPaused:Boolean  [read-only]


Implementation
    public function get parsingPaused():Boolean
Constructor Detail
ParserBase()Constructor
public function ParserBase(format:String)

Creates a new ParserBase object

Parameters
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

away3d.loading.parsers.ParserDataFormat
Method Detail
addDependency()method
protected function addDependency(id:String, req:URLRequest, retrieveAsRawData:Boolean = false, data:* = null, suppressErrorEvents:Boolean = false):void

Parameters

id:String
 
req:URLRequest
 
retrieveAsRawData:Boolean (default = false)
 
data:* (default = null)
 
suppressErrorEvents:Boolean (default = false)

constructSubGeometries()method 
protected function constructSubGeometries(verts:Vector.<Number>, indices:Vector.<uint>, uvs:Vector.<Number>, normals:Vector.<Number>, tangents:Vector.<Number>, weights:Vector.<Number>, jointIndices:Vector.<Number>):Vector.<SubGeometry>

Build a list of sub-geometries from raw data vectors, splitting them up in such a way that they won't exceed buffer length limits.

Parameters

verts:Vector.<Number>
 
indices:Vector.<uint>
 
uvs:Vector.<Number>
 
normals:Vector.<Number>
 
tangents:Vector.<Number>
 
weights:Vector.<Number>
 
jointIndices:Vector.<Number>

Returns
Vector.<SubGeometry>
constructSubGeometry()method 
protected function constructSubGeometry(verts:Vector.<Number>, indices:Vector.<uint>, uvs:Vector.<Number>, normals:Vector.<Number>, tangents:Vector.<Number>, weights:Vector.<Number>, jointIndices:Vector.<Number>):SubGeometry

Build a sub-geometry from data vectors.

Parameters

verts:Vector.<Number>
 
indices:Vector.<uint>
 
uvs:Vector.<Number>
 
normals:Vector.<Number>
 
tangents:Vector.<Number>
 
weights:Vector.<Number>
 
jointIndices:Vector.<Number>

Returns
SubGeometry
dieWithError()method 
protected function dieWithError(message:String = Unknown parsing error):void

Parameters

message:String (default = Unknown parsing error)

finalizeAsset()method 
protected function finalizeAsset(asset:IAsset, name:String = null):void

Parameters

asset:IAsset
 
name:String (default = null)

finishParsing()method 
protected function finishParsing():void

Finish parsing the data.

getByteData()method 
protected function getByteData():ByteArray

Returns
ByteArray
getTextData()method 
protected function getTextData():String

Returns
String
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.
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)

parseAsync()method 
public function parseAsync(data:*, frameLimit:Number = 30):void

Parse data (possibly containing bytearry, plain text or BitmapAsset) asynchronously, meaning that the parser will periodically stop parsing so that the AVM may proceed to the next frame.

Parameters

data:* — The untyped data object 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.

pauseAndRetrieveDependencies()method 
protected function pauseAndRetrieveDependencies():void

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.

resumeParsingAfterDependencies()method 
arcane function resumeParsingAfterDependencies():void

Event Detail
animationNodeComplete Event
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when an animation node has been constructed from a resource.

animationSetComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when an animation set has been constructed from a group of animation state resources.

animationStateComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when an animation state has been constructed from a group of animation node resources.

animatorComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when a animator asset has been constructed from a resource.

assetComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when any asset finishes parsing. Also see specific events for each individual asset type (meshes, materials et c.)

containerComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when a container asset has been constructed from a resource.

geometryComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when a geometry asset has been constructed from a resource.

materialComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when a material asset has been constructed from a resource.

parseComplete Event  
Event Object Type: away3d.events.ParserEvent
ParserEvent.type property = away3d.events.ParserEvent

Dispatched when the parsing finishes.

parseError Event  
Event Object Type: away3d.events.ParserEvent
ParserEvent.type property = away3d.events.ParserEvent

Dispatched if an error was caught during parsing.

readyForDependencies Event  
Event Object Type: away3d.events.ParserEvent
ParserEvent.type property = away3d.events.ParserEvent

Dispatched when parser pauses to wait for dependencies, used internally to trigger loading of dependencies which are then returned to the parser through it's interface in the arcane namespace.

skeletonComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when a skeleton asset has been constructed from a resource.

skeletonPoseComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when a skeleton pose asset has been constructed from a resource.

stateTransitionComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when an animation state transition has been constructed from a group of animation node resources.

textureComplete Event  
Event Object Type: away3d.events.AssetEvent
AssetEvent.type property = away3d.events.AssetEvent

Dispatched when a texture asset has been constructed from a resource.

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.