com.flagstone.transform.button
Class ButtonSound

java.lang.Object
  extended by com.flagstone.transform.button.ButtonSound
All Implemented Interfaces:
Copyable<MovieTag>, SWFEncodeable, MovieTag

public final class ButtonSound
extends Object
implements MovieTag

ButtonSound defines the sounds that are played when an event occurs in a button. Sounds are only played for the RollOver, RollOut, Press and Release events.

For each event a SoundInfo object identifies the sound and controls how it is played. For events where no sound should be played simply specify a null value instead of a SoundInfo object.

See Also:
DefineButton, DefineButton2

Constructor Summary
ButtonSound(ButtonSound object)
          Creates and initialises a ButtonSound object using the values copied from another ButtonSound object.
ButtonSound(int uid, Event eventCode, SoundInfo aSound)
          Creates a ButtonSound object that defines the sound played for a single button event.
ButtonSound(SWFDecoder coder)
          Creates and initialises a ButtonSound object using values encoded in the Flash binary format.
 
Method Summary
 ButtonSound copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 int getIdentifier()
          Get the unique identifier of the button that this object applies to.
 SoundInfo getSoundInfo(Event event)
          Returns the SoundInfo object for the specified event.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setIdentifier(int uid)
          Sets the identifier of the button that this object applies to.
 void setSoundInfo(Event event, SoundInfo info)
          Sets the SoundInfo object for the specified button event.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ButtonSound

public ButtonSound(SWFDecoder coder)
            throws IOException
Creates and initialises a ButtonSound object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

ButtonSound

public ButtonSound(int uid,
                   Event eventCode,
                   SoundInfo aSound)
Creates a ButtonSound object that defines the sound played for a single button event.

Parameters:
uid - the unique identifier of the DefineButton or DefineButton2 object that defines the button. Must be in the range 1..65535.
eventCode - the event that identifies when the sound id played, must be either Event.EventType.rollOver, Event.EventType.rollOut, Event.EventType.press or Event.EventType.release.
aSound - an SoundInfo object that identifies a sound and controls how it is played.

ButtonSound

public ButtonSound(ButtonSound object)
Creates and initialises a ButtonSound object using the values copied from another ButtonSound object.

Parameters:
object - a ButtonSound object from which the values will be copied.
Method Detail

getIdentifier

public int getIdentifier()
Get the unique identifier of the button that this object applies to.

Returns:
the unique identifier of the sound.

getSoundInfo

public SoundInfo getSoundInfo(Event event)
Returns the SoundInfo object for the specified event. Null is returned if there is no SoundInfo object defined for the event code.

Parameters:
event - The button event, must be one of Event.ROLL_OVER, Event.ROLL_OUT, Event.PRESS, Event.RELEASE.
Returns:
the SoundInfo that identifies and controls the sound that will be played for the event or null if not SoundInfo is defined for the event.

setIdentifier

public void setIdentifier(int uid)
Sets the identifier of the button that this object applies to.

Parameters:
uid - the unique identifier of the button which this object applies to. Must be in the range 1..65535.

setSoundInfo

public void setSoundInfo(Event event,
                         SoundInfo info)
Sets the SoundInfo object for the specified button event. The argument may be null allowing the SoundInfo object for a given event to be deleted.

Parameters:
event - the code representing the button event, must be either Event.EventType.RollOver, Event.EventType.RollOut, Event.EventType.Press or Event.EventType.Release.
info - an SoundInfo object that identifies and controls how the sound is played.

copy

public ButtonSound copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<MovieTag>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()

Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.