Flagstone Software

Flash Concepts - Identifiers

When an object (button, image, sound, etc.) is created for a movie it is assigned a unique identifier. This identifier is an unsigned, 16-bit number and should be unique within the movie*. Any instruction that manipulates an object, such as adding it to the display list uses this identifier to reference the object.

In Transform the FSMovie class is used to keep track of identifiers. When creating a movie the newIdentifier() method can be used to generate a new identifier. The identifiers are tracked using a simple counter which can be preset to generate identifiers with any value - subject of course to a maximum value of 65,535.

If you load a movie then the internal counter is updated every time a new definition is decoded. Once a movie is loaded the counter will contain the identifier of the highest object definition decoded. This allows you to safely add new objects to a movie without interfering with any existing ones.

*Actually this is not strictly true. If an object is no longer being used you can re-use the identifier with another object. When the Flash Player loads the definition of an object it is stored in an internal dictionary using the identifier as a key. This is the reason identifiers can be reused. However if you reuse an identifier for a sound and it was originally assigned to an image you had better make sure the the image definition is reloaded should your movie ever loop back and reference the image again. Dictionary entries may be deleted using an FSFree object once a definition is no longer needed.