Skip to main content
Gotta Dance
Inspiring
December 16, 2022
Question

Expressions: Trace / Alert Reporting ?

  • December 16, 2022
  • 2 replies
  • 235 views

Hi everybody,

 

In the Flash/Actionscript days, we'd run a trace() to get a test or variable response. In HTML5 or anything DOM-based we'd place an alert() to get a basic response for routines. 

 

What is used in AFX expressions to make sure a value or variable is being defined or seen by the processor? I tried the term Alert() to try and get a value to echo but it gave me a syntax error. 

 

You guys (and gals) have been great, thanks!

This topic has been closed for replies.

2 replies

Mylenium
Legend
December 17, 2022

Comment out the parts that work to debug the ones that don't, apply expressions to text layers or inert expression controls just to plot the output values without making e.g. an effect crash.

 

Mylenium

Dan Ebberts
Community Expert
Community Expert
December 17, 2022

Ah yes. Debugging complex expressions can require some resourcefulness. Say you have an expression like this, and it isn't generating an error, but it isn't giving the result you expect:

a = 1;
b = 2;
c = a + b;
d = 4;
c + d;

You suspect that variable c might be the culprit, so you append a throw() to your expression, like this:

a = 1;
b = 2;
c = a + b;
d = 4;
c + d;
throw("c = " + c)

Now you'll get an error message and at the bottom of it will be: c = 3

Another thing you can do is to apply your expression (possibly with some modifications required) to the Source Text property of a text layer and comment out certain lines so that the expression just gets to a particular variable you're interested in and the result will be displayed in the text layer. 

Or sometimes you can just append a variable name to the end of an expression that isn't working, but isn't generating an error message just to check the value of a particular variable (remember that the last value calculated in an expression is the one that gets reported as the result). 

There are a lot of little tricks like that you'll learn along the way...