Packagestarling.assets
Classpublic class JsonFactory
InheritanceJsonFactory Inheritance AssetFactory Inheritance Object

This AssetFactory creates objects from JSON data.



Public Properties
 PropertyDefined By
 Inheritedpriority : int
AssetFactory
Public Methods
 MethodDefined By
  
Creates a new instance.
JsonFactory
 Inherited
addExtensions(... args):void
Add one or more file extensions (without leading dot) that identify the supported data types.
AssetFactory
 Inherited
addMimeTypes(... args):void
Add one or more mime types that identify the supported data types.
AssetFactory
  
canHandle(reference:AssetReference):Boolean
[override] Returns 'true' if this factory can handle the given reference.
JsonFactory
  
create(reference:AssetReference, helper:AssetFactoryHelper, onComplete:Function, onError:Function):void
[override] This method will only be called if 'canHandle' returned 'true' for the given reference.
JsonFactory
 Inherited
getExtensions(out:Vector.<String> = null):Vector.<String>
Returns the file extensions this factory supports.
AssetFactory
 Inherited
getMimeTypes(out:Vector.<String> = null):Vector.<String>
Returns the mime types this factory supports.
AssetFactory
Constructor Detail
JsonFactory()Constructor
public function JsonFactory()

Creates a new instance.

Method Detail
canHandle()method
override public function canHandle(reference:AssetReference):Boolean

Returns 'true' if this factory can handle the given reference. The default implementation checks if extension and/or mime type of the reference match those of the factory.

Parameters

reference:AssetReference

Returns
Boolean
create()method 
override public function create(reference:AssetReference, helper:AssetFactoryHelper, onComplete:Function, onError:Function):void

This method will only be called if 'canHandle' returned 'true' for the given reference. It's responsible for creating at least one concrete asset and passing it to 'onComplete'.

Parameters

reference:AssetReference — The asset to be created. If a local or remote URL is referenced, it will already have been loaded, and 'data' will contain a ByteArray.
 
helper:AssetFactoryHelper — Contains useful utility methods to be used by the factory. Look at the class documentation for more information.
 
onComplete:Function — To be called with the name and asset as parameters when loading is successful.
function(name:String, asset:Object):void;
 
onError:Function — To be called when creation fails for some reason. Do not call 'onComplete' when that happens.
function(error:String):void