Box

From MegaZine3
Jump to: navigation, search
ASUL Component
Tag name box
Extends AbstractAsulObject

This is a primitive container. It is used as the base class for most other components.

Contents

Attributes

alpha

This defines the normal alpha (opacity) of the element. Can be a floating point value in an interval of [0, 1]. Default value is 1, i.e. fully visible.

Example

<box anchors="20,20,pw/2,ph-20" background="color(0x990000)" alpha="0.25"/>
<box anchors="pw/2,20,pw-20,ph-20" background="color(0x990000)" alpha="0.75"/>
Results in the following:

alpha_fadetime

This attribute only applies when alpha_out is set. In that case it determines the time in milliseconds it should take for the shift from one transparency to the other. Can be an integer value larger or equal to zero.

alpha_out

An alternative alpha value for when the mouse cursor is not hovering the object. As the normal alpha value, this can be a floating point value in an interval of [0, 1]. Defaults to the same value as given in alpha, so no fading.

Note: the element must be either mouseenabled or have mouseenabled children.

Example

<box anchors="20,20,pw-20,ph-20" background="color(0x990000)" alpha_out="0.5"
     mouseenabled="true" alpha_fadetime="2"/>
Results in the following:

collapse_time

The time in seconds it should take to collapse the element to the collapse_height and collapse_width.

Example

<box x="20" y="20" width="60" height="60" background="color(0x990000)"
     collapse_height="30" collapse_time="0.5" mouseenabled="true"/>
Results in the following:

collapse_height

The height to collapse the element to while it is not hovered by the mouse.

collapse_width

The width to collapse the element to while it is not hovered by the mouse.

filter

Set a filter effect for this element. Available filter are: glow, dropshadow, bevel and blur. Those simply create a filter as provided by the Flash API.

A filter has to be given in common definition format, i.e. type(arguments). Multiple filters can be given when separated by semicolons (;). The first argument is always the filter type, the following arguments differ between the filter types, but are equivalent to the arguments taken by the filter classes' constructors. Please refer to the Flash API documentation for more information:

Example

<box anchors="0,0,pw,ph" background="color(0x660000)">
    <box anchors="20,20,pw-20,ph-20" background="color(0x990000)" filter="dropshadow(2,45,0x000000,1,3,3,0.5,2); glow(0xFFFFFF,1,3,3,1,2)"/>
</box>
Results in the following:

mouseenabled

Whether this element is mouseenabled or not, i.e. whether the user can interact with this element element using the mouse or not. This must be set to true for all elements that should allow mouse interaction, e.g. buttons. This is also true if the element contains a loaded SWF file that should allow mouse interaction.

title

This can be used to assign a title to an element. If set, hovering the element opens a tooltip with the specified text. This can also be a localize definition, i.e. a string of the format localize(LOCALIZE_ID, Default text).

Note: the element must be either mouseenabled or have mouseenabled children.

Example

<box anchors="0,0,pw,ph" background="color(0x990000)" title="Title!" mouseenabled="true"/>
Results in the following:

Event attributes

These attributes, defined the same way as other attributes, are special in such that they contain script code which is evaluated when an event corresponding to the attribute occurs. This is similar to the principle of event attributes in HTML, and naming was inspired by those.

Whenever the script in such an attribute is evaluated, a variable named event is made available in the script context. This variable will be the original ActionScript3 event variable representing the event.

In general it is possible to put any code whatsoever into event attributes, but for readability and reuseability it is recommended to define the actual handler functions in script block and then calling that function.

onadded

Event attribute. The contained script is evaluated when Flash's Event.ADDED occurs for this object.

onaddedtostage

Event attribute. The contained script is evaluated when Flash's Event.ADDED_TO_STAGE occurs for this object.

onclick

Event attribute. The contained script is evaluated when Flash's MouseEvent.CLICK occurs for this object.

Example

<button anchors="20,20,pw-20,ph-20" background="color(0x660000)" onclick="event.currentTarget.alpha=Math.random()"/>
Results in the following:

oninvisible

Event attribute. The contained script is evaluated when Flash's VisibilityEvent.INVISIBLE occurs for this object, i.e. when its visibility property changes to true.

onkeydown

Event attribute. The contained script is evaluated when Flash's KeyboardEvent.KEY_DOWN occurs for this object.

onkeyup

Event attribute. The contained script is evaluated when Flash's KeyboardEvent.KEY_UP occurs for this object.

onmousedown

Event attribute. The contained script is evaluated when Flash's MouseEvent.MOUSE_DOWN occurs for this object.

onmousemove

Event attribute. The contained script is evaluated when Flash's MouseEvent.MOUSE_MOVE occurs for this object.

onmouseout

Event attribute. The contained script is evaluated when Flash's MouseEvent.MOUSE_OUT occurs for this object.

onmouseover

Event attribute. The contained script is evaluated when Flash's MouseEvent.MOUSE_OVER occurs for this object.

onmouseup

Event attribute. The contained script is evaluated when Flash's MouseEvent.MOUSE_UP occurs for this object.

onmousewheel

Event attribute. The contained script is evaluated when Flash's MouseEvent.MOUSE_WHEEL occurs for this object.

onremoved

Event attribute. The contained script is evaluated when Flash's Event.REMOVED occurs for this object.

onremovedfromstage

Event attribute. The contained script is evaluated when Flash's Event.REMOVED_FROM_STAGE occurs for this object.

onresize

Event attribute. The contained script is evaluated when Flash's Event.RESIZE occurs for this object, i.e. when its size changes.

onrollout

Event attribute. The contained script is evaluated when Flash's MouseEvent.ROLL_OUT occurs for this object.

onrollover

Event attribute. The contained script is evaluated when Flash's MouseEvent.ROLL_OVER occurs for this object.

onvisible

Event attribute. The contained script is evaluated when Flash's VisibilityEvent.VISIBLE occurs for this object, i.e. when its visibility property changes to true.

ASUL-related articles
Components Box · Button · ProgressBar · ScrollBar · ScrollPane · Text · ToggleButton · Window
Layouts Horizontal Flow Layout · Vertical Flow Layout
ASUL Articles ASUL Document · Editing the GUI · Layouting · ASUL scripting
Personal tools
Namespaces
Variants
Actions
Navigation
documentation
miscellaneous
Toolbox