Get behavior instance

function GetThisBehavior(inst)
{
    var i, len;
    for (i = 0, len = inst.behavior_insts.length; i < len; i++)
    {
        if (inst.behavior_insts[i] instanceof behaviorProto.Instance)
            return inst.behavior_insts[i];
    }
        return null;
};

See the official DragnDrop behavior.
"behaviorProto" could be changed to specific behavior.

timescale of object

To get dt of instance, use
var dt = this.runtime.getDt(inst);

But only plugin which has "type" to "world" would have my_timescale property. So my_timescale need to be added manually for other case.
For example:
this.my_timescale = -1

Reorder z order of layer

Step1. Get layer
var layer = inst.layer;
or
var layer = (typeof layerparam == "number")?
            this.runtime.getLayerByNumber(layerparam):
            this.runtime.getLayerByName(layerparam);


Step2. Sort the list layer.instances
layer.instances(SORTFN);
for example
function sortInstanceByZIndex(a, b)
{

    return a.zindex - b.zindex;
}

Step3. reassign zindex of instances in this layer.
layer.zindices_stale = true;


Reference