Animation with APL 1.3 Time functionality

Frank Börncke

Animation with APL 1.3 Time functionality

With the introduction of APL 1.3 we also received a tiny little new feature: a top level so called "Time" property now gives us direct access to time and date right within the APL template.

The obvious use case for this functionality is to make it easy to implement clock functionality into Alexa skills that work right from within the APL. No lambda required.

Update dynamic properties at runtime with Time-API

Now it turns out there are some other use cases for this Time feature which are not that obvious: The idea is to (mis/ab)-use the dynamic nature of the timer API for simple auto updating animations and content updates that do not require APL command execution. Such animations even proceed to run while Alexa is waiting for user feedback or while there is an ongoing utterance.

Why does this work? Every APL property which is marked as "dynamic" can be updated via runtime using Time-API. Unfortunately this technique will not work with so called "styled properties" which would be an even greater thing to have.

Some use cases

This concept gives us a number of options:

  • Text can be updated in a loop. I found this useful to auto update hint texts every some seconds even if the user does not interact with the skill. This might help him to get an idea how to proceed.

  • Properties like opacity and color can be updated automatically to build smooth effects.

  • Prepared values from an array can be accessed using Time-results as index. I found this flipbook like approach extremly powerful to run simple effects.

  • Using chains of Emojis you can build some nice self running animations.

  • What is great: the APL "transform" property will evaluate and update the Time values within its settings. This allows rotation and rescaling running as endless loop in the background.

The example code given here shows a "rocket" and a "heartbeat" animation demonstrating what is possible.

Find out more about this approach on https://github.com/fboerncke/alexa-time-api-abuse

DownloadOpen in Editor
5
Views8
0
Likes1
Share
Supported Viewport Profiles
  • Hub Landscape, Small
  • Hub Landscape, Medium
  • Hub Landscape, Large
  • TV Fullscreen
Minimum required APL version1.8
Comments

Be the first to comment.