Class: Utils

b5. Utils

new b5.Utils()

utils/utils.js, line 7

Generic utility functionality

Methods

staticb5.Utils.findObjectFromPath(path, type){object}

utils/utils.js, line 112

Finds an actor, scene, timeline or actions list object from a path of the form scene_name.actor_name....

Name Type Description
path string

Path to object,, such as scene1.actor1.timeline1

type string

Type of resource (can be timeline, actions, or undefined for scene or actor)

Returns:
Type Description
object The found object or null if not found

staticb5.Utils.findResourceFromPath(path, type){object}

utils/utils.js, line 158

Finds a resource object from a path of the form scene_name.resource_name

Name Type Description
path string

Path to resource, for example scene1.shape1

type string

Type of resource (brush, sound, shape, material, bitmap)

Returns:
Type Description
object The found resource or null if not found

staticb5.Utils.getResFromType(parent, type){object}

utils/utils.js, line 217

Returns the correct resource buffer based on resourced type

Name Type Description
parent object

Parent resource container

type string

The type of resource

Returns:
Type Description
object The resource buffer or null if not found

staticb5.Utils.loadJS(filename)

utils/utils.js, line 79

Adds a JavaScript file to the head of the document

Name Type Description
filename string

File name

staticb5.Utils.loadJSON(filename, blocking, callback, binary){boolean}

utils/utils.js, line 26

Loads a JSON file

Name Type Description
filename string

File name

blocking boolean

If true then file will be loaded synchronously, otherwise asynchronously

callback

(function) Callback that will be called when the file has been downloaded

binary

(boolean) If true then data is returned as binary

Returns:
Type Description
boolean true if success, false if error

staticb5.Utils.LogExtern(url)

utils/utils.js, line 94

Sends a string to an external URL, used or logging

Name Type Description
url string

URL + data

staticb5.Utils.resolveObject(obj_or_path, type){object}

utils/utils.js, line 184

Takes an object or an object path and returns the found object

Name Type Description
obj_or_path object | string

Instance of object or path to object

type string

Type of resource (can be timeline, actions, or undefined for scene or actor)

Returns:
Type Description
object The found object or null

staticb5.Utils.resolveResource(res_or_path, type){object}

utils/utils.js, line 200
Name Type Description
res_or_path string

Instance of resource or path to resource, for example scene1.shape1

type string

Type of resource (brush, sound, shape, material, bitmap)

Returns:
Type Description
object The found resource or null if not found

staticb5.Utils.sortLayers(objs)

utils/utils.js, line 243

Used by actors and scenes to sort their children into layers

Name Type Description
objs object

Actor or scene array