|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSTransformObject
com.flagstone.transform.FSClipEvent
public class FSClipEvent
FSClipEvent is used to define the actions that a movie clip will execute in response to a particular event.
FSClipEvent objects are added to an FSPlaceObject2 object and the actions are registered with the Flash Player when the movie clip is added to the display list.
Attributes | |
---|---|
event | A code representing one or more events that the movie clip will respond to. |
actions | An array of actions that will be executed when one or more of the specified events occur. |
encodedActions | An array of bytes containing encoded actions can also be set. The encoded actions are typically generated by the parser in the Translate framework. The actions array and encodedActions cannot both be valid at the same time. Accessor methods used to set either of the attributes will set the other to null. |
The events that a movie clip responds to are:
Event | Description |
---|---|
Load | occurs when the movie clip is finished loading. |
Unload | occurs when the movie clip is unloaded from the parent movie. |
EnterFrame | occurs when each frame in the movie clip is played. |
MouseMove | occurs when the mouse pointer is moved. |
MouseDown | occurs when the left mouse button is pressed while the cursor is outside of the bounding rectangle of the movie clip. |
MouseUp | occurs when the left mouse button is pressed and released while the cursor is outside of the bounding rectangle of the movie clip. |
KeyDown | occurs when any key is pressed on the keyboard. From Flash 6 a key code can be specified to identify a specific key rather than testing for the value inside the actions that are executed in response to the event. |
KeyUp | occurs when any key being pressed on the keyboard is released. |
Data | occurs when an FSGetUrl2 action is executed with the movie clip specified as a target. |
Starting with Flash 6 movie clips also respond to the same set of events that buttons do:
RollOver | occurs when the mouse cursor moves over the movie clip. |
RollOut | occurs when the mouse cursor moves out of the bounding rectangle of the movie clip. |
Press | occurs when the mouse button is clicked while the mouse cursor is inside bounding rectangle of the movie clip. |
Release | occurs when the mouse button is clicked and released while the mouse cursor is inside bounding rectangle of the movie clip. |
ReleaseOut | occurs when the mouse button is clicked and the mouse cursor is released outside of the bounding rectangle of the movie clip. |
DragOut | occurs when the mouse button is clicked and the mouse cursor is dragged out of the bounding rectangle of the movie clip. |
DragOver | occurs when the mouse button is clicked, the mouse cursor is dragged into the bounding rectangle of the movie clip and the mouse button is released. |
Initialize | occurs when a movie clip is initialized using the FSInitialize class. |
Movie clips now also respond to keys being pressed on the keyboard. Keyboard events are defined by the character key being pressed, e.g. "t", "T", "$", etc. The ASCII code for the key is used to identify which key was pressed. Note that while multiple mouse events can be defined for a button only one keyboard event can be defined.
In Flash 7 a new construct event was added.
Construct | The function of this event is undocumented. |
IMPORTANT: The FSClipEvent object supports both the Flash 5, Flash 6 and Flash 7 event models. The events that are encoded to a file are determined by the version of the FSMovie in which the object is contained. The codes assigned to the different types of event ensure that the same value can be used to encode the object for each version of Flash.
For the KeyDown and KeyUp events, Flash ActionScript provides the Key object which contains the getCode() and isDown() functions that allow code to be written to test which key was pressed. Note that ActionScript is a high-level interpreted language similar to JavaScript. Transform supports actions that represent the compiled version of the ActionScript code. To create and compile ActionScript code then use Transform's sister product, Translate.
Each type of event is defined by a constant, for example, Load, EnterFrame, etc. An FSClipEvent object can define the actions that will be executed in response to multiple events. There are two ways to respond to multiple events. If the same set of actions should be executed then the event code that flags which events should be responded to can be generated by bitwise OR-ing together the individual constants:
int loadAndMouseMove = FSClipEvent.Load | FSClipEvent.MouseMove;
If different actions should be executed then an FSClipEvent object is created for each different set of events. The FSPlaceObject2 object that is used to register the actions for a movie clip with the Flash Player supports an array of FSClipEvent objects.
The array of actions may be empty. Although this situation does not perform any useful operation it is valid and may be encountered when parsing Flash files generated by a third party.
The following simplified code fragments illustrate how the FSClipEvent class can be used.
1. Defining the actions for a single event.
FSDefineMovieClip movieClip = new FSDefineMovieClip(movie.newIdentifier(), commands); FSClipEvent clipEvent(FSClipEvent.MouseDown); clipEvent.add(anAction); ... FSPlaceObject2 placeClip = new FSPlaceObject2(movieClip.getIdentifier(), 1, events, 400, 400); placeClip.add(clipEvent); movie.add(movieClip); movie.add(placeClip);
2. Defining the actions for a compound event.
If a movie clip should
execute the same set of actions for different types of event then the code
for the compound event can be created by bitwise-OR'ing individual event
codes.
FSDefineMovieClip movieClip = new FSDefineMovieClip(movie.newIdentifier(), commands); FSClipEvent clipEvent(FSClipEvent.MouseDown | FSClipEvent.KeyDown, actions); ... FSPlaceObject2* placeClip = new FSPlaceObject2(movieClip.getIdentifier(), 1, events, 400, 400) placeClip.add(clipEvent); movie.add(movieClip); movie.add(placeClip);
3. Defining different sets of actions for events.
An FSClipEvent object
is created for each set of events that a movie clip must respond to.
FSDefineMovieClip* movieClip = new FSDefineMovieClip(movie.newIdentifier(), commands); FSPlaceObject2* placeClip = new FSPlaceObject2(movieClip.getIdentifier(), 1, events, 400, 400) FSClipEvent mouseEvent(FSClipEvent.MouseDown, mouseActions); ... placeClip.add(clipEvent); FSClipEvent keyEvent(FSClipEvent.KeyDown, keyActions); ... placeClip.add(keyEvent); movie.add(movieClip); movie.add(placeClip);
The FSClipEvent class represents the ClipEvent data structure tag from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 5. The event model was extended in Flash 6 to support the set of events that Buttons respond to. In Flash 7 the Construct event was added.
Field Summary | |
---|---|
static int |
Construct
Code for a construct event. |
static int |
Data
Code for a data event. |
static int |
DragOut
Code for a drag out event. |
static int |
DragOver
Code for a drag over event. |
static int |
EnterFrame
Code for an enter frame event. |
static int |
Initialize
Code for an initialise event. |
static int |
KeyDown
Code for a key down event. |
static int |
KeyPress
Code for a key press event, where the code for the key is specified. |
static int |
KeyUp
Code for a key up event. |
static int |
Load
Code for a load event. |
static int |
MouseDown
Code for a mouse down event. |
static int |
MouseMove
Code for a mouse move event. |
static int |
MouseUp
Code for a mouse up event. |
static int |
Press
Code for a press event. |
static int |
Release
Code for a release event. |
static int |
ReleaseOut
Code for a release outside event. |
static int |
RollOut
Code for a roll out event. |
static int |
RollOver
Code for a roll over event. |
static int |
Unload
Code for an unload event. |
Constructor Summary | |
---|---|
FSClipEvent(FSClipEvent obj)
Constructs an FSCall object by copying values from an existing object. |
|
FSClipEvent(FSCoder coder)
Construct an FSClipEvent object, initialising it with values decoded from an encoded object. |
|
FSClipEvent(int eventCode,
java.util.ArrayList anArray)
Constructs an FSClipEvent object that defines the array of actions that will be executed when a particular event occurs. |
|
FSClipEvent(int eventCode,
byte[] bytes)
Constructs an FSClipEvent object that defines the array of actions that will be executed when a particular event occurs. |
|
FSClipEvent(int eventCode,
int keyCode,
java.util.ArrayList anArray)
Constructs an FSClipEvent object that defines the array of actions that will be executed when a particular event occurs or when the specified key is pressed. |
|
FSClipEvent(int eventCode,
int keyCode,
byte[] bytes)
Constructs an FSClipEvent object that defines the array of actions that will be executed when a particular event occurs or when the specified key is pressed. |
Method Summary | |
---|---|
void |
add(FSActionObject anAction)
Adds an action to the array of actions. |
void |
appendDescription(java.lang.StringBuffer buffer,
int depth)
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. |
java.lang.Object |
clone()
Creates a deep copy of the entire object. |
void |
decode(FSCoder coder)
|
void |
encode(FSCoder coder)
|
boolean |
equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. |
java.util.ArrayList |
getActions()
Gets the array of actions that are executed by the movie clip in response to specified event(s). |
byte[] |
getEncodedActions()
Get the array of encoded actions that are executed when the frame is displayed. |
int |
getEvent()
Gets the event code that this FSClipEvent defines actions for. |
int |
getKeyCode()
Gets the code for the key that triggers the event when pressed. |
int |
length(FSCoder coder)
|
void |
setActions(java.util.ArrayList anArray)
Sets the array of actions that are executed by the movie clip in response to specified event(s). |
void |
setEncodedActions(byte[] bytes)
Set the array of encoded actions generated by the classes in the Translate framework. |
void |
setEvent(int aNumber)
Sets the event code that this FSClipEvent defines actions for. |
void |
setKeyCode(int code)
Sets the code for the key that triggers the event when pressed. |
Methods inherited from class com.flagstone.transform.FSTransformObject |
---|
name, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int Load
public static final int EnterFrame
public static final int Unload
public static final int MouseMove
public static final int MouseDown
public static final int MouseUp
public static final int KeyDown
public static final int KeyUp
public static final int Data
public static final int Initialize
public static final int Press
public static final int Release
public static final int ReleaseOut
public static final int RollOver
public static final int RollOut
public static final int DragOver
public static final int DragOut
public static final int KeyPress
public static final int Construct
Constructor Detail |
---|
public FSClipEvent(FSCoder coder)
coder
- an FSCoder containing the binary data.public FSClipEvent(int eventCode, java.util.ArrayList anArray)
eventCode
- the code representing one or more events.anArray
- the array of actions that will be executed when the specified
event occurs.public FSClipEvent(int eventCode, byte[] bytes)
eventCode
- the event code.bytes
- an array of encoded action objects.public FSClipEvent(int eventCode, int keyCode, java.util.ArrayList anArray)
eventCode
- the code representing one or more events.keyCode
- the ASCII code for the key pressed on the keyboard.anArray
- the array of actions that will be executed when the specified
event occurs.public FSClipEvent(int eventCode, int keyCode, byte[] bytes)
eventCode
- the code representing one or more events.keyCode
- the ASCII code for the key pressed on the keyboard.bytes
- an array of encoded action objects.public FSClipEvent(FSClipEvent obj)
obj
- an FSCall object.Method Detail |
---|
public void add(FSActionObject anAction)
anAction
- a pointer to an action object.public void setEvent(int aNumber)
aNumber
- the code representing one or more events.public int getEvent()
public int getKeyCode()
public void setKeyCode(int code)
code
- the ASCII code for the key that triggers the event.public void setActions(java.util.ArrayList anArray)
anArray
- the array of actions that will be executed when the specified
event occurs.public java.util.ArrayList getActions()
public byte[] getEncodedActions()
public void setEncodedActions(byte[] bytes)
bytes
- the array of encoded actions.public java.lang.Object clone()
FSTransformObject
clone
in class FSTransformObject
public boolean equals(java.lang.Object anObject)
equals
in class FSTransformObject
public void appendDescription(java.lang.StringBuffer buffer, int depth)
FSTransformObject
appendDescription
in class FSTransformObject
buffer
- a StringBuffer to which the description of each object is
appended.depth
- the maximum level of nesting up to which objects will be
displayed.public int length(FSCoder coder)
length
in class FSTransformObject
public void encode(FSCoder coder)
encode
in class FSTransformObject
public void decode(FSCoder coder)
decode
in class FSTransformObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |