Graphics Reference
In-Depth Information
Not only can you create a new symbol instance with script, you can also re-
move existing symbols in the same manner. The deleteSymbol() function
is used for this task. It completely deletes the symbol and removes all symbol
elements from the DOM. This is currently the only way to clean the Stage's DOM
during the course of an animation. Simply disabling or hiding an element or
symbol means that the corresponding data in both the DOM and the memory
remain intact.
// Delete element that is an instance of a symbol.
// (getSymbol searches the object symbol for a
// Symbolinstanceelement)
sym.getSymbol("Symbol1").deleteSymbol();
5.5.8 Working with Symbol Variables
For interactive and dynamic compositions, it is often necessary to store values
intermittently. On one hand, you have the option to declare a variable within an
action as follows:
var userName = sym.$("userNameInput").html();
If you need the variable only within the action, this local variable is sufficient.
Due to the local scope, you cannot access variables from outside, such as from
the Stage. As soon as access to the variable from another action or another
symbol is required, we need to save the value differently. The need for external
access might involve the score in a game, which is stored on the Stage and
called from various child symbols.
In such a scenario, you can simply store the values in the global scope, which
can be accessed from everywhere. However, this procedure is absolutely bad
practice, since it can very quickly lead to name conflicts (global scope pollution)
that produce undesirable side effects. Edge Animate offers the option to set so-
called symbol variables on the instance level of a symbol. The functions sym.
setVariable() and sym getVariable() are available for this procedure.
The exact signature of both functions is as follows:
// Set symbol variable
sym.setVariable( KEY, VALUE );
// Read symbol variable
var value = sym.getVariable( KEY );
 
Search WWH ::




Custom Search