Macromedia Flash File Format (SWF)

recompiled with RAW HTWL

Sprites


Introduction Basic Types Display List Control Tags
Shapes (Examples Shapes) Gradients Buttons
Sprites Fonts and Text Shape Morphing Bitmap
Sounds Actions ActionScripts Reference

Sprites and Movie Clips Contents

Sprites and Movie Clips
Sprite Names
DefineSprite
QuickTime™ Movies

Sprites and Movie Clips

A sprite corresponds to a ‘movie clip’ in the Flash user-interface. It is a Macromedia Flash (SWF) movie contained within a Macromedia Flash (SWF) movie, and supports many of the features of a regular Flash movie, including: A sprite object is defined with a DefineSprite tag. It consists of a character ID, a frame count, and a series of control tags. Definition tags (such as DefineShape ) are not allowed in the DefineSprite tag. All the characters referred to by control tags in the sprite must be defined outside the sprite, and before the DefineSprite tag.

Once defined, a sprite is displayed with a PlaceObject2 tag in the main movie. The transform (specified in PlaceObject) is concatenated with the transforms of objects placed inside the sprite. These objects behave like ‘children’ of the sprite, so when the sprite is moved, the objects inside the sprite move also. Similarly, when the sprite is scaled or rotated, the child objects are also scaled or rotated. A sprite object stops playing automatically when it is removed from the display list.

Sprite Names

When a sprite is placed on the display list, it can be given a name with the PlaceObject2 tag. This name corresponds to the instance name in the Macromedia Flash user-interface. It is used to identify the sprite so the main movie (or other sprites) can perform actions inside the sprite. This is achieved with the SetTarget action (called ‘Tell Target’ in the Flash user-interface)

For example, say a sprite object was placed in the main movie with the name “spinner”. The main movie can send this sprite to the first frame in its timeline with the following action sequence:
  1. SetTarget “spinner” 2. GotoFrame zero 3. SetTarget “” (empty string) 4. End of actions. (Action code = 0)
Note: All actions following SetTarget “spinner” apply to the spinner object until SetTarget “”, which sets the action context back to the main movie.

Macromedia Flash (SWF) supports placing sprites within sprites, which can lead to complex hierarchies objects. To handle this complexity Macromedia Flash (SWF) uses a naming convention similar to that used by file systems to identify sprites.

For example, the following outline shows four sprites defined within the main movie:
MainMovie.swf
    SpriteA (name: Jack)
        SpriteA1 (name: Bert)
        SpriteA2 (name: Ernie)
    SpriteB (name: Jill)
The following SetTarget paths identify the sprites above:

DefineSprite

The DefineSprite tag defines a sprite character. It consists of a character ID and a frame count, followed by a series of control tags. The sprite is terminated with an End tag.

Definition tags (such as DefineShape ) are not allowed in the DefineSprite tag. All the characters referred to by control tags in the sprite must be defined in the main body of the file before the sprite is defined.
     DefineSprite     
     Field           Type           Comment     
     Header           RECORDHEADER           Tag ID = 39     
     Sprite ID           UI16           ID of sprite     
     FrameCount           UI16           Number of frames in Sprite.     
     ControlTags           TAG[one or more]           A series of tags     
    SwfJava v0.0: how to create a DefineSprite object    
    new DefineSprite (    
        int spriteID,    
        TagEnumeration tags    
    );    


    XWF v0.0: how to declare a DefineSprite tag    
    <DefineSprite id="(ID)" >    
        <tag1 > ... </tag1>    
        <tag2 > ... </tag2>    
        ...    
    </DefineSprite>    


The valid tags within a DefineSprite tag are as follows:

QuickTime™ Movies

A QuickTime movie is defined with the DefineMovie tag. It is defined using an external reference to a file or URL. A movie character can be placed on the Display List like any other character.
     DefineMovie     
     Field           Type           Comment     
     Header           RECORDHEADER           Tag ID = 38     
     Sprite ID           UI16           ID of Movie     
     MovieName           STRING           Filename or URL of the movie.     
    SwfJava v0.0: how to create a DefineMovie object    
        
    {not yet implemented}    
        


Introduction Basic Types Display List Control Tags
Shapes (Examples Shapes) Gradients Buttons
Sprites Fonts and Text Shape Morphing Bitmap
Sounds Actions ActionScripts Reference