Notifications let you know that something happened inside a Symbol layer.
For example, if you use Symbol to display a switch control, the Symbol may receive a notification when the switch is turned on or off.
First, let's look at how to configure your scenes to send notifications. Here are two scenes representing a Switch control:
When you click the Switch button on the "Switch On" scene, it will automatically transition to the "Switch Off" scene. Likewise, when you click the Switch button on the "Switch Off" scene, it will automatically transition to the "Switch On" scene.
By default, these scenes do not send any notifications. Let's add some.
When the Switch is turned on (which means that the "Switch On" scene has just appeared), we want to send the notification that the Switch was turned on.
To add the notification:
- Select the "Switch On" scene:
Click on the yellow event circle displayed in the top right corner of the scene
Pick "Scene Appeared" event from the displayed menu. This means that the notification will be sent when this scene ("Switch On") appears:
- Next, click the "Send Notification to Enclosing Symbol" placeholder that appears at the center top of your workspace:
- Drama will ask you which notification should be sent to the enclosing symbol. Pick "New Notification":
- A new scene event will now appear in the Inspector. As you can see, this new event will be triggered when scene appears (at the start of the transition in this case, but you can change this if you wish). As a reaction to the scene appearing, a notification "Notification 1" will be sent:
- Change the "Notification 1" here to something meaningful, like "Turned On". You can simply rewrite the name of the notification in the text field:
After appearing in a Symbol layer, the "Switch On" scene will now automatically send notification "Turned On". We can follow similar steps and add "Turned Off" notification for the "Switch Off" scene.
Now, let's look at how we can actually use these notifications. Here we have a scene named "Light" that uses the "Switch Off" scene inside a Symbol:
The switch should be used here to toggle between light and dark mode. As the switch is turned on, we want to transition to the other, dark mode scene:
Here's how to add an event that will be triggered by the Turned On notification of the Switch control:
Select Symbol layer on Light scene
Click on the yellow add event button:
Now, you can see that aside from the usual event options, there are also "Turned On" and "Turned Off" notifications available. These are the notifications we just added. Pick "Turned On".
Next, click on the Dark Scene to indicate that you wish to add a transition to the Dark Scene:
That's it! We've just added a new Symbol event that will transition to Dark Scene when the Symbol receives the "Turned On" notification.
Notifications are a very powerful concept. This example was pretty simple, but you can create really advanced controls with complex internal behavior. By using Symbols and Notifications, all that complexity can stay hidden away inside the Symbol. Actually using your custom advanced controls will then be easy - simply make a Symbol and listen to its notifications.