Ordered [loadbang] Update

Here is the updated version which allows you to set the order with any number including negatives and decimals, which should be useful for collecting groups of events together. If you instantiate the object with any other arguments these will be sent on load instead of the usual “bang” so the object functions as a [loadmess] replacement too.

// lh.loadbang.js

var loader = new Global("loader");
loader.num = 0;
loader.all = [];

var inst = jsarguments[1];

var t = new Task(poll);
t.interval = 10;

function poll() {
    if (loader.all[loader.num] == inst) {
        if (jsarguments.length > 2) {
            outlet(0,jsarguments.slice(2));
        } else {
            outlet(0,"bang");
        }
        loader.num++;
        arguments.callee.task.cancel();
    }
}

function loadbang() {
    if (!max.loadbangdisabled) {
        if (typeof(inst) == "number") {
            loader.all.push(inst);
        }
        loader.all.sort(up);
        t.repeat();
    }
}

function up(a,b) {
    return a-b;
}

autowatch = 1;

// EOF
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s