The onAnimate attribute allows custom stimulus animations to be programmed.
Name | Type | Description |
---|---|---|
script | script | One or more expressions, delimited by semi-colons. See help with expression syntax for more information. |
This parameter executes the enclosed custom expressions prior to presenting a stimulus animation frame. The script can change properties on a given stimulus such as size, position, or color according to custom logic in order to implement complex animations. The animation parameter must be set to "dynamic" in order for this code to executed.
The following shape includes a custom animation that alternates between to screen positions:
<shape example>
/ shape = rectangle
/ color = red
/ size = (50%, 50%)
/ position = (50%, 50%)
/ animation = dynamic(500, -1)
/ onAnimate = [
if(values.toggle)
{
shape.redsquare.hposition = 75%;
}
else
{
shape.redsquare.hposition = 50%;
}
values.toggle = !values.toggle;
]
</shape>