Table of Contents

Example

Playback - Set fade-in time - modular

by: Sebastian Beutel, April 2021
published: here
description: set some playbacks' fade-in time, modular macros
remarks: these macros incorporate some newer syntax details: instruction blocks, custom variables, macros refered in other macros

The basic functions are best understood when comparing with Playback - Set fade-in time. When using Handles.SetSourceHandle() which always refers to the handle index on the current page you need to make sure that there is actually something suitable present in this location - hence, some steps need to be conditional. Additionally when you want to make such macros for n different times and m different playbacks you need to repeat many lines of code.

Using newer syntax with code blocks and custom variables this is way easier: here we create only one macro to set all relevant playbacks' fade time to a variable value (using the block syntax to put a few instructions under one condition). Additionally a number of rather short macros simply sets the time variable to a certain value and then calls the 'apply' macro:

functions

affected properties

control structures

specials

Code

SetFadeInNew.xml
<?xml version="1.0" encoding="utf-8"?>
<avolites.macros>
  <macro id="Wiki.Macros.SetFadeIn" name="Set Fade In (2)">
    <variables>
      <object id="Time" type="Avolites.Acw.Titan.AcwTimeSpan" assembly="Avolites.Acw.Titan" value="2" />
    </variables>
    <sequence>
      <step>
        {
          Handles.SetSourceHandle("PlaybackWindow", 0);
          if (Playbacks.IsCueHandle(Handles.SourceHandle) == true)
          {
            ActionScript.SetProperty("Playbacks.Editor.SelectedPlayback", Handles.SourceHandle);
            Playbacks.Editor.SelectLiveCue();
            ActionScript.SetProperty("Playbacks.Editor.Times.CueFadeInTime", Wiki.Macros.SetFadeIn.Time);
          }
          Handles.ClearSelection();
        }
      </step>
      <step>
        {
          Handles.SetSourceHandle("PlaybackWindow", 1);
          if (Playbacks.IsCueHandle(Handles.SourceHandle) == true)
          {
            ActionScript.SetProperty("Playbacks.Editor.SelectedPlayback", Handles.SourceHandle);
            Playbacks.Editor.SelectLiveCue();
            ActionScript.SetProperty("Playbacks.Editor.Times.CueFadeInTime", Wiki.Macros.SetFadeIn.Time);
          }
          Handles.ClearSelection();
        }
      </step>
      <step>
        {
          Handles.SetSourceHandle("PlaybackWindow", 2);
          if (Playbacks.IsCueHandle(Handles.SourceHandle) == true)
          {
            ActionScript.SetProperty("Playbacks.Editor.SelectedPlayback", Handles.SourceHandle);
            Playbacks.Editor.SelectLiveCue();
            ActionScript.SetProperty("Playbacks.Editor.Times.CueFadeInTime", Wiki.Macros.SetFadeIn.Time);
          }
          Handles.ClearSelection();
        }
      </step>
    </sequence>
  </macro>
  <macro id="Wiki.Macros.SetFadeIn0" name="Set Fade In 0">
    <sequence>
      <step>ActionScript.SetProperty("Wiki.Macros.SetFadeIn.Time", time:0)</step>
      <step>UserMacros.RecallMacroById("Wiki.Macros.SetFadeIn")</step>
    </sequence>
  </macro>
  <macro id="Wiki.Macros.SetFadeIn1" name="Set Fade In 1">
    <sequence>
      <step>ActionScript.SetProperty("Wiki.Macros.SetFadeIn.Time", time:1)</step>
      <step>UserMacros.RecallMacroById("Wiki.Macros.SetFadeIn")</step>
    </sequence>
  </macro>
</avolites.macros>

Explanation

This explains the functional steps within the sequence. For all the other XML details please refer to Formats and syntax

The Main macro Wiki.Macros.SetFadeIn defines a custom variable Wiki.Macros.SetFadeIn.Time, than selects a number of playbacks, and sets them to this time.

if (condition)
      {
        code being executed only if condition is true
      }

The calling macros Wiki.Macros.SetFadeIn0, Wiki.Macros.SetFadeIn1 etc. now are really short:

How to use it

  1. if you want to add more playbacks to be affected simply add more steps in the 'main macro' Wiki.Macros.SetFadeIn
  2. if you want to add more fade-teime valus then you only need to add some more 'calling macros'