Made to Order Software Corporation Logo

Declare Dictionary

SWF Action
Action Category: 
Objects
Action Details: 
0
Action Identifier: 
136
Action Structure: 
unsigned short    f_count;
string   f_dictionary[f_count];
Action Length: 
-1 byte(s)
Action Stack: 
n.a.
Action Operation: 
<n.a.>
Action Flash Version: 
5
See Also: 

Declare an array of strings that will later be retrieved using the Push Data action with a dictionary lookup. There can be a maximum of 65534 strings. The visibility of a dictionary is within its DoAction or other similar block of actions. Note that you should have only one Declare Dictionary. The dictionary is visible from everywhere in the DoAction. In other words, you can access it from functions1, With blocks, try/catch/finally blocks, etc.

When multiple Declare Dictionary actions are used, only the last one found is in force when Push Data actions are encountered.2

Note that a Declare Dictionary is only useful for optimization. A Push Data can be used to push a string on the stack without the need of a Declare Dictionary. In other words, since it requires 2 or 3 bytes in a Push Data to retrieve a string, strings of 1 character are never needed in a dictionary. Also, a string used only once does not need to be in a dictionary. Finally, a Declare Dictionary action requires an extra overhead of 3 bytes3. So if the only thing you have to put in it is a rather small string used twice, again, it may not save you anything.

IMPORTANT NOTE

To ensure proper functionality, it is advised that you put the Declare Dictionary at the very beginning of your blocks of actions and use only one of them. With the limit of 65534 entries, you will first reach the size limit  of the Declare Dictionary and not unlikely of the block of actions. It is therefore not possible that you'd ever exhaust the available size offered by this action.

  • 1. Declare Function and Declare Function 2 both accept accesses to Declare Dictionary.
  • 2. I never tested in a loop. Side effects could very well happen in that case... it may use one or the other when you branch before a Declare Dictionary... TBD
  • 3. One byte for the action code and 2 bytes for the size.