Options
Menu

Class ParserBase

ParserBase provides an abstract base export class for objects that convert blocks of data to data structures supported by away.

If used by Loader to automatically determine the parser type, two public static methods should be implemented, with the following signatures:

public static supportsType(extension : string) : boolean Indicates whether or not a given file extension is supported by the parser.

public static 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

Loader

Hierarchy

Index

Constructors

constructor

  • Creates a new ParserBase object

    see

    away.loading.parsers.ParserDataFormat

    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.

    Returns ParserBase

Properties

_iFileName

_iFileName: string

_isParsing

_isParsing: boolean

_pContent

_pContent: IAsset

Static MORE_TO_PARSE

MORE_TO_PARSE: boolean

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

Static PARSING_DONE

PARSING_DONE: boolean

Returned by proceedParsing to indicate no more parsing is needed.

Accessors

content

  • Returns IAsset

data

  • get (): any
  • Returns any

dataFormat

  • get (): string
  • The data format of the file data to be parsed. Options are URLLoaderDataFormat.BINARY, URLLoaderDataFormat.ARRAY_BUFFER, URLLoaderDataFormat.BLOB, URLLoaderDataFormat.VARIABLES or URLLoaderDataFormat.TEXT.

    Returns string

dependencies

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

    Returns Array<ResourceDependency>

materialMode

  • get (): number
  • set (newMaterialMode: number): void
  • Returns number

  • Parameters

    • newMaterialMode: number

    Returns void

parsingComplete

  • get (): boolean
  • Returns boolean

parsingFailure

  • get (): boolean
  • set (b: boolean): void
  • Returns boolean

  • Parameters

    • b: boolean

    Returns void

parsingPaused

  • get (): boolean
  • Returns boolean

Methods

_iResolveDependency

  • 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

    Returns void

_iResolveDependencyFailure

  • Resolve a dependency loading failure. Used by parser to eventually provide a default map

    Parameters

    Returns void

_iResolveDependencyName

  • Resolve a dependency name

    Parameters

    Returns string

_iResumeParsing

  • _iResumeParsing(): void
  • Returns void

_pAddDependency

  • _pAddDependency(id: string, req: URLRequest, retrieveAsRawData?: boolean, data?: any, suppressErrorEvents?: boolean, sub_id?: number): ResourceDependency
  • Parameters

    • id: string
    • req: URLRequest
    • Default value retrieveAsRawData: boolean = false
    • Default value data: any = null
    • Default value suppressErrorEvents: boolean = false
    • Default value sub_id: number = 0

    Returns ResourceDependency

_pDieWithError

  • _pDieWithError(message?: string): void
  • Parameters

    • Default value message: string = "Unknown parsing error"

    Returns void

_pFinalizeAsset

  • _pFinalizeAsset(asset: IAsset, name?: string): void
  • Parameters

    • asset: IAsset
    • Default value name: string = null

    Returns void

_pFinishParsing

  • _pFinishParsing(): void
  • Finish parsing the data.

    Returns void

Private _pGetByteData

  • Returns ByteArray

Private _pGetData

  • _pGetData(): any
  • Returns any

Private _pGetTextData

  • _pGetTextData(): string
  • Returns string

_pHasTime

  • _pHasTime(): 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.

_pOnInterval

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

    Parameters

    Returns void

_pPauseAndRetrieveDependencies

  • _pPauseAndRetrieveDependencies(): void
  • Returns void

_pPauseParsing

  • _pPauseParsing(): void
  • Returns void

_pProceedParsing

  • _pProceedParsing(): boolean
  • Parse the next block of data.

    Returns boolean

    Whether or not more data needs to be parsed. Can be ParserBase.ParserBase.PARSING_DONE or ParserBase.ParserBase.MORE_TO_PARSE.

_pStartParsing

  • _pStartParsing(frameLimit: number): void
  • Initializes the parsing of data.

    Parameters

    • frameLimit: number

      The maximum duration of a parsing session.

    Returns void

addEventListener

  • addEventListener(type: string, listener: function): void
  • Add an event listener

    method

    addEventListener

    Parameters

    • type: string
    • listener: function

    Returns void

dispatchEvent

hasEventListener

  • hasEventListener(type: string, listener?: function): boolean
  • check if an object has an event listener assigned to it

    method

    hasListener

    Parameters

    • type: string
    • Optional listener: function

    Returns boolean

parseAsync

  • parseAsync(data: any, frameLimit?: number): 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: any

      The untyped data object in which the loaded data resides.

    • Default value frameLimit: number = 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.

    Returns void

removeEventListener

  • removeEventListener(type: string, listener: function): void
  • Remove an event listener

    method

    removeEventListener

    Parameters

    • type: string
    • listener: function

    Returns void

Static supportsType

  • supportsType(extension: string): boolean
  • Parameters

    • extension: string

    Returns boolean

Generated using TypeDoc