pluginProto.onCreate = function ()
{
// Override the 'set width' action
pluginProto.acts.SetWidth = function (w)
{
if (this.width !== w)
{
this.width = w;
this.text_changed = true; // also recalculate text wrapping
this.set_bbox_changed();
}
};
See the official text plugin.
The common ACEs could be found in commonace.js
Showing posts with label ACE. Show all posts
Showing posts with label ACE. Show all posts
Create instance
instanceProto.CreateInst = function (objtype,x,y,_layer)
{
var layer = (typeof _layer == "number")?
this.runtime.getLayerByNumber(_layer):
(typeof _layer == "string")?
this.runtime.getLayerByName(_layer):
_layer;
// call system action: Create instance
cr.system_object.prototype.acts.CreateObject.call(
this.runtime.system,
objtype,
layer,
x,
y
);
return objtype.getFirstPicked(); // return the created instance
};
Reference
{
var layer = (typeof _layer == "number")?
this.runtime.getLayerByNumber(_layer):
(typeof _layer == "string")?
this.runtime.getLayerByName(_layer):
_layer;
// call system action: Create instance
cr.system_object.prototype.acts.CreateObject.call(
this.runtime.system,
objtype,
layer,
x,
y
);
return objtype.getFirstPicked(); // return the created instance
};
Reference
Reuse system action
cr.system_object.prototype.acts.SetLayerEffectParam.call(
this.runtime.system, // this
param0,
....
);
this.runtime.system, // this
param0,
....
);
Reuse ACE
Reuse action/condition/expression from other plugin.
Action cr.plugins_.WebStorage.prototype.acts.StoreLocal.call(webstorage_obj, key, value);
Condition
cr.plugins_.WebStorage.prototype.cnds.LocalStorageExists.call(webstorage_obj, key);
Expression
var fake_ret = {
value:0,
set_any: function(value){this.value=value;},
set_int: function(value){this.value=value;},
set_float: function(value){this.value=value;},
set_string: function(value) {this.value=value;},
};
cr.plugins_.WebStorage.prototype.exps.LocalValue.call(webstorage_obj, fake_ret, key);
return fake_ret.value
Get instance
var plugins = this.runtime.types;
var name, inst;
for (name in plugins)
{
inst = plugins[name].instances[0];
if (inst instanceof cr.plugins_.WebStorage.prototype.Instance)
{
// get target instance
}
}
Action cr.plugins_.WebStorage.prototype.acts.StoreLocal.call(webstorage_obj, key, value);
Condition
cr.plugins_.WebStorage.prototype.cnds.LocalStorageExists.call(webstorage_obj, key);
Expression
var fake_ret = {
value:0,
set_any: function(value){this.value=value;},
set_int: function(value){this.value=value;},
set_float: function(value){this.value=value;},
set_string: function(value) {this.value=value;},
};
cr.plugins_.WebStorage.prototype.exps.LocalValue.call(webstorage_obj, fake_ret, key);
return fake_ret.value
Get instance
var plugins = this.runtime.types;
var name, inst;
for (name in plugins)
{
inst = plugins[name].instances[0];
if (inst instanceof cr.plugins_.WebStorage.prototype.Instance)
{
// get target instance
}
}
Reference - webstorage extension plugin
Subscribe to:
Posts (Atom)