Mixin: ResourceObjectMixin

xebra.js v1.2.5 - Documentation

ResourceObjectMixin

Request and manage remote resources from the Max seach path. A resource includes both metadata, like image size and file type, as well as the file data itself. Only images are currently supported.

This Mixin is currently applied to instances of ObjectNode representing fpic, live.tab and live.text.

Example

// An ObjectNode that uses resources will return a nonzero value from getResourceCount
const fpicObject;
const resourceCount = fpicObject.getResourceCount(); // Will always be one

// To get a specific resource, use the getResourceAtIndex function
const resource = fpicObject.getResourceAtIndex(0);

// ObjectNodes that use resources will manage those resources on their own. If you'd like
// to handle the data for that resource as well, then you must register another listener.
// The resource doesn't hold on to data from Max once it receives it, so be sure to listen for Resource.event:data_received
// events in order to handle resource data.
resource.on("data_received", (filename, data_uri) => {
// Do something with the data
});

// For resources that belong to an ObjectNode, it doesn't make sense to set the filename and
// dimensions properties of the resource directly. Rather, you can set the parameters of the
// ObjectNode, and it will manage resources itself.
fpicObject.setParamValue("pic", "alex.png"); // Will request new resource data.

Methods

getResourceAtIndex(idx)

Name Type Description
idx number

The resource index

Throws:

throws an error if the resource index is out of bounds

getResourceCount():number

Returns:
Type Description
number number of available resources

Events

ResourceObjectMixin.event:resources_changed

Resources Changed event. Fired internally whenever an object node has a new array of resources.

Name Type Description
object ObjectNode

This