Macromedia Flash File Format (SWF)

recompiled with RAW HTWL

Actions


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

Actions Contents

Actions
Macromedia Flash (SWF) 3 Action Model
The DoAction Tag
ActionRecords
Macromedia Flash (SWF) 4 Action Model
Stack Operations
Arithmetic Operators
Numerical Comparison
Logical Operators
String Manipulation
Type Conversion
Control Flow
Variables
Movie Control
Utilities
Macromedia Flash (SWF) 5 Action Model
ScriptObject Actions
Type Actions
Math Actions
Stack Operator Actions

Actions

Actions are an essential part of an interactive Macromedia Flash movie. Actions allow a movie to react to events such as mouse movements of mouse clicks. Macromedia Flash (SWF) version 3 (and earlier) supports a simple action model. Macromedia Flash (SWF) version 4 supports a greatly enhanced action model including an expression evaluator, variables, and conditional branching and looping. Macromedia Flash (SWF) version 5 adds a JavaScript-style object model, data types and functions. Macromedia Flash (SWF) 3 Action Model

Macromedia Flash (SWF) 3 Action Model

The Macromedia Flash (SWF) version 3 action model consists of eleven simple instructions for the Macromedia Flash Player:
Play – start playing at the current frame.
Stop – stop playing at the current frame.
NextFrame – go to the next frame
PreviousFrame – go to the previous frame
GotoFrame – go to the specified frame
GotoLabel – go to the frame with the specified label
WaitForFrame – wait for the specified frame
GetURL – get the specified URL.
StopSounds – stop all sounds playing
ToggleQuality – toggle the display between high and low quality.
SetTarget – change the context of subsequent actions to a named object.
An action (or list of actions) can be triggered by a button state transition, or by a DoAction tag. The action is not executed immediately, but is added to a list of actions to be processed. The list is executed on a ShowFrame tag, or after the button state has changed. An action can cause other actions to be triggered, in which case, the action is added to the list of actions to be processed. Actions are processed until the action list is empty.

By default, timeline actions such as Stop, Play and GoToFrame apply to movie that contains them. However, the SetTarget action (called ‘Tell Target’ in the Macromedia Flash user-interface) can be used to send an action command to another movie or sprite (see DefineSprite )

There are 127 possible actions of which 91 are currently defined.

The DoAction Tag

The DoAction flag tells the Macromedia Flash player to perform a list of actions when the current frame is complete. The actions are performed when the ShowFrame tag is encountered.
     DoAction     
     Field           Type           Comment     
     Header           RECORDHEADER           Tag ID = 12     
     Actions           ACTIONRECORD[zero or more]           List of actions to perform - see below     
     ActionEndFlag           UI8 = 0           Always set to 0     
    SwfJava v0.0: how to create a DoAction object    
    new DoAction (    
        ActionRecord [] actions    
    );    


    XWF v0.0: how to declare a DoAction tag    
    <DoAction>    
        <action ... />    
        <action ... />    
        ...    
    </DoAction>    


ActionRecords

An action record consists of a 1-byte action code. If the high bit of the action code is set, then there is a 16-bit length that describes the amount of data used by the action. If the high bit is clear, the action has no data.
     ActionRecord     
     Field           Type           Comment     
     ActionCode           code = UI8           An action code as specified below     
     Length           If code >= 0x80 UI16           The number of bytes (after this) in the ACTIONRECORD     
    SwfJava v0.0: how to create a ActionRecord object    
        
    all actions below are derived from ActionRecord    
        


ActionGotoFrame

Instructs the player to go to the specified frame in the current movie.
     ActionGotoFrame     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x81     
     Length           UI16           Always 2     
     Frame           UI16           Frame index     
    SwfJava v0.0: how to create a ActionGotoFrame object    
    new GotoFrame (    
        int frame    
    );    


    XWF v0.0: how to declare a GotoFrame action    
    <GotoFrame frame="(int)" />    



The first frame in the movie has number 0.

ActionGetURL

Instructs the player to get the URL specified by UrlString. The URL can be of any type, including an HTML file, an image or another SWF movie. If the movie is playing in a browser, the URL will be displayed in the frame specified by TargetString. The special target names “_level0” and “_level1” are used to load another SWF movie into levels 0 and 1 respectively.
     ActionGetURL     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x83     
     Length           UI16           Combined length of strings     
     UrlString           STRING           Target URL string     
     TargetString           STRING           Target string     
    SwfJava v0.0: how to create a ActionGetURL object    
    new GetURL (    
        String url, String target    
    );    


    XWF v0.0: how to declare a GetURL action    
    <GetURL URL="(string)" target="(string)" />    


ActionNextFrame

Instructs the player to go to the next frame in the current movie.
     ActionNextFrame     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x04     
    SwfJava v0.0: how to create a ActionNextFrame object    
        
    new NextFrame();    
        


    XWF v0.0: how to declare a NextFrame action    
    <NextFrame />    


ActionPreviousFrame

Instructs the player to go to the previous frame of the current movie.
     ActionPreviousFrame     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x05     
    SwfJava v0.0: how to create a ActionPreviousFrame object    
        
    new PreviousFrame();    
        


    XWF v0.0: how to declare a PreviousFrame action    
    <PreviousFrame />    


ActionPlay

Instructs the player to start playing at the current frame.
     ActionPlay     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x06     
    SwfJava v0.0: how to create a ActionPlay object    
        
    new Play();    
        


    XWF v0.0: how to declare a Play action    
    <Play />    



A simple sequence to use this action is: Insert a DoAction with the Stop action. Define a Button where the action is Play. Place this button on the Display List. Show the current Frame. When the user clicks on the button, it will launch the action Play, so the current frame will continue its play, then movie goes normally to the next frame.
I think the only difference between Play and NextFrame is that Play spends a 1/frameRateth of a second before the next frame plays.

ActionStop

Instructs the player to stop playing the movie at the current frame.
     ActionStop     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x07     
    SwfJava v0.0: how to create a ActionStop object    
        
    new Stop();    
        


    XWF v0.0: how to declare a Stop action    
    <Stop />    



If a sequence of actions is Stop, GotoFrame(x), the GotoFrame action is executed without stopping. Why this behaviour?

ActionToggleQuality

Toggle the display between high and low quality.
     ActionToggleQuality     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x08     
    SwfJava v0.0: how to create a ActionToggleQuality object    
        
    new ToggleQuality();    
        


    XWF v0.0: how to declare a ToggleQuality action    
    <ToggleQuality />    


ActionStopSounds

Instructs the player to stop playing all sounds.
     ActionStopSounds     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x09     
    SwfJava v0.0: how to create a ActionStopSounds object    
        
    new StopSounds();    
        


    XWF v0.0: how to declare a StopSounds action    
    <StopSounds />    


ActionWaitForFrame

Instructs the player to wait until the specified frame, otherwise skip the specified number of actions.
     ActionWaitForFrame     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x8A     
     Length           UI16           Always 3     
     Frame           UI16           Frame to wait for     
     SkipCount           UI8           Number of actions to skip if frame is not loaded     
    SwfJava v0.0: how to create a ActionWaitForFrame object    
    new WaitForFrame (    
        int frame,    
        int skipCount    
    );    


    XWF v0.0: how to declare a WaitForFrame action    
    <WaitForFrame frame="(int)" skipCount="(int)" />    


ActionSetTarget

Instructs the player to change the context of subsequent actions, so they apply to a named object (TargetName) rather than the current movie.

For example, the SetTarget action can be used to control the timeline of a sprite object. The following sequence of actions sends a sprite called “spinner” to the first frame in its timeline:
  1. SetTarget “spinner”
  2. GotoFrame zero
  3. SetTarget “” (empty string)
  4. End of actions. (Action code = 0)
All actions following SetTarget “spinner” apply to the spinner object until SetTarget “”, which sets the action context back to the current movie. For a complete discussion of target names see DefineSprite .
     ActionSetTarget     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x8B     
     Length           UI16           Length of record     
     TargetName           STRING           Target of action target     
    SwfJava v0.0: how to create a ActionSetTarget object    
    new SetTarget (    
        String target    
    );    


    XWF v0.0: how to declare a SetTarget action    
    <SetTarget target="(string)" />    


ActionGotoLabel

Instructs the player to go to frame associated with the specified label. A label can be attached to a frame with the FrameLabel tag.
     ActionGotoLabel     
     Field           Type           Comment     
     ActionCode           UI8           Action = 0x8C     
     Length           UI16           Length of record     
     Label           STRING           Frame label     
    SwfJava v0.0: how to create a ActionGotoLabel object    
    new GotoLabel (    
        String label    
    );    


    XWF v0.0: how to declare a GotoLabel action    
    <GotoLabel label="(string)" />    


Macromedia Flash (SWF) 4 Action Model

to be continued…

Macromedia Flash (SWF) 5 Action Model

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