Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorLightDimmer
Behavior element behavior adding dimming support to ECBehaviorLight.
This behavior modifies the light parameters of ECBehaviorLight instances present in the element to make lights gently raise and lower intensity when (de)activated.
To use this behavior add first an ECBehaviorLight. Adding ECBehaviorLightDimmer will then register itself as listener to the ECBehaviorLight and also set it to use custom light handling.
This behavior can be used multiple times on an element to affect different lights. Use the behavior identifier to tell them apart.
Element class properties have the prefix lightDimmer.
or lightDimmer({id}).
if id is not empty.
Set time in seconds required to raise light intensity to full brightness.
lightDimmer.timeRaise
or lightDimmer({id}).timeRaise
<float name='lightDimmer.timeRaise'>0.5</float>
Set time in seconds required to lower light intensity to 0 intensity.
lightDimmer.timeLower
or lightDimmer({id}).timeLower
<float name='lightDimmer.timeLower'>0.5</float>
This behavior has no events.
This behavior does not support optional behaviors.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which contains a light with dimming support.
class MyElement extends BehaviorElementClass public var ECBehaviorLight light public var ECBehaviorLightDimmer lightDimmer func new() light = ECBehaviorLight.new(this, null) lightDimmer = ECBehaviorLightDimmer.new(this, light) lightDimmer.getTimeRaise().setValue(2) lightDimmer.getTimeLower().setValue(0.5) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorLight'/> <behavior type='ECBehaviorLightDimmer'> <!-- optional: use light with id instead of empty string --> <string name='light'>second</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <float name='.timeRaise'>1.5</float> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorLightDimmer' id='second'/> </elementClass>