Components
The following properties can be used in any component.
API Examples
// 1. In Editor, "File" - "Open with Visual Studio Code" to open VS Code
// 2. Create a js file
// 3. Copy and Paste the code to the js file, save the js file.
// 4. Back to Editor, Add a button to a page
// 5. Assigh "test_origin" to the button.
// 6. Play.
registerAction("test_origin", "", "test_origin", "");
function test_origin() {
// get properties
var x = getProperty(self, "x");
var y = getProperty(self, "y");
var w = getProperty(self, "width");
var h = getProperty(self, "height");
print("before x", x);
print("before y", y);
if (typeof firstTime == "undefined") {
firstTime = true;
} else {
firstTime = false;
}
// only set one time
if (firstTime) {
// set the origin
var factor = 0.5;
setProperty(self, "origin_x", factor); // range (0 - 1) 1 means the width of the component
setProperty(self, "origin_y", factor); // range (0 - 1) 1 means the height of the component
print("origin x", getProperty(self, "origin_x")); // return value is in pixels
print("origin y", getProperty(self, "origin_y")); // return value is in pixels
// get origin in decimal
var origin_x = getProperty(self, "origin_x") / w;
var origin_y = getProperty(self, "origin_y") / h;
// set back the position of the component
setProperty(self, "x", x + origin_x * w);
setProperty(self, "y", y + origin_y * h);
print("after x", getProperty(self, "x"));
print("after y", getProperty(self, "y"));
}
// animation
setPropertyIn(self, "angle", 36000, 1000);
setPropertyIn(self, "angle", 0, 1010);
}
Properties
| Property | Type | Description |
|---|---|---|
| form_enabled | bool | A Boolean value that indicates whether the value of the component will be submitted along with the form |
| passed_form_validation | bool | A Boolean value that indicates whether the component has passed the form validation |
| form_field_name | string | The name will be saved when the form is submitted |
| alpha | number | Set the alpha level for a component |
| visible | bool | A Boolean value that indicates whether the component is visible |
| hidden | bool | A Boolean value that indicates whether the component is hidden |
| lock_width | bool | When true, the width of the component will be use millimeter positioning |
| lock_height | bool | When true, the height of the component will be use millimeter positioning |
| lock_width_size | number | Set the width of a component in millimeters |
| lock_height_size | number | Set the height of a component in millimeters |
| lock_left | bool | When true, the left of the component will be use millimeter positioning |
| lock_right | bool | When true, the right of the component will be use millimeter positioning |
| lock_top | bool | When true, the top of the component will be use millimeter positioning |
| lock_bottom | bool | When true, the bottom of the component will be use millimeter positioning |
| lock_left_size | number | Set the left of a component in millimeters |
| lock_right_size | number | Set the right of a component in millimeters |
| lock_top_size | number | Set the top of a component in millimeters |
| lock_bottom_size | number | Set the bottom of a component in millimeters |
| unique_id | string | Read Only. A unique Id for components |
| instance_display_name | string | Read Only. The name of the component in the Umajin Editor |
| type | string | Read Only. Specifies the type of the component. e.g. Button, text |
| parent | string | Read Only. Specifies the “unique_id” of the parent component. e.g. 0000025209C39AA0 |
| x | number | The x-coordinate of the top-left of the component in pixels |
| y | number | The y-coordinate of the top-left of the component in pixels |
| width | number | Specifies how wide a component is in pixels |
| height | number | Specifies how height a component is in pixels |
| opacity | string | Set the opacity level for a component |
| angle | number | The angle, in degrees |
| scale | number | Default is 1. Scale factor |
| scale_width | number | Default is 1. Scale factor on the x-coordinate, the anchor point is (0, 0) |
| scale_height | number | Default is 1. Scale factor on the y-coordinate, the anchor point is (0, 0) |
| origin_x | float (0 – 1) | Refer to the API Example |
| origin_y | float (0 – 1) | Refer to the API Example |
| mask | string | An optional layer whose alpha channel is used to mask the component’s content |
Events
These can be used with bindEvent or raiseEvent.
| Event | Params | Description |
|---|---|---|
| on_down | (x, y, touchIndex) | Occurs when a user touches down on the component. |
| on_up | (x, y, touchIndex) | Occurs when a user lifts up on the component. It can be occur outside of the component. |
| on_press | (x, y, touchIndex) | A up event is called before “on_up”. Only will be called when the finger is inside the bounds of the component |
| on_move | (x, y, touchIndex) | This event will be raised when a user moves while maintaining a down state. e.g. if the user drags right by 100 pixels it will fire off several on_move events. |