• Keep in touch:
  • Linked In
  • Twitter
  • RSS

What is an identifier?

Every instruction that defines an object in a movie, such as a shape, button or sound must be assigned an identifier, in the range 1..65535. This identifier is used to identify the object when, for example, adding it to the display list.

    int imageId = 1;
    int layer = 1;
    int x = 2000;
    int y = 1600;

    DefineImage image = constructor.defineImage(imageId);
    
    movie.add(Place2.show(imageId, layer, x, y));
    movie.add(ShowFrame.getInstance());

When the Flash Player loads a movie it stores all the object definitions in an internal dictionary using the unique identifier as a key. This means that you must define an object before you make reference to it, otherwise the behaviour of the Flash Player is undefined - if you are lucky the object will not be displayed but you might also crash the Flash Player.

In Transform, all classes that define an object such as a shape, sound, etc. implement the DefineTag interface which contains the methods getIdentifier() and setIdentifier() to get and set the unique identifier.

Notes

  1. Identifiers with a value of zero are treated as a special null identifier. These are rarely used in day-to-day Flash files.
  2. Transform stores identifiers using the int data type for convenience. Methods used to set identifiers do perform range checking and an exception will be thrown if the value is outside the range 0..65535.
  3. Since the identifier is used as a dictionary key, you can reuse them if you re-define an object, though obviously this is a potential source of bugs that would be hard to track down.