com.flagstone.transform
Class FSDefineTextField

java.lang.Object
  extended by com.flagstone.transform.FSTransformObject
      extended by com.flagstone.transform.FSMovieObject
          extended by com.flagstone.transform.FSDefineObject
              extended by com.flagstone.transform.FSDefineTextField
All Implemented Interfaces:
java.lang.Cloneable

public class FSDefineTextField
extends FSDefineObject

FSDefineTextField defines an editable text field.

The value entered into the text field is assigned to a specified variable allowing the creation of forms to accept values entered by a person viewing the Flash file.

The class contains a complex set of attributes which allows a high degree of control over how a text field is displayed:

Attributes
type Identifies the data structure when it is encoded. Read-only.
identifier An unique identifier for this object in the range 1..65535.
bounds The bounding rectangle for the text field.
wordWrap Indicates whether the text should be wrapped.
multiline Indicates whether the text field contains multiple lines.
password Indicates whether the text field will be used to display a password.
readOnly Indicates whether the text field is read only.
selectable Indicates whether the text field is selectable.
bordered Indicates whether the text field is bordered.
HTML Indicates whether the text field contains HTML.
fontIdentifier The identifier of the font displayed in the text field.
height The height of the characters in twips.
useFontGlyphs Use either the glyphs defined in the movie to display the text or load the specified from the platform on which the Flash Player is hosted.
autosize Indicates whether the text field will resize automatically to fit the text entered.
colour The colour of the text. If set to null then the text colour defaults to black.
maxLength The maximum length of the text field. May be set to zero is not maximum length is defined.
variableName The name of the variable the text will be assigned to.
initialText The default text displayed in the text field.

Additional layout information for the spacing of the text relative to the text field borders can also be specified through the following set of attributes:

alignment Whether the text in the field is left-aligned, right-aligned, centred.
leftMargin Left margin in twips.
rightMargin Right margin in twips.
indent Text indentation in twips.
leading Leading in twips.

The default values for the alignment is AlignLeft while the leftMargin, rightMargin indent and leading attributes are set to the constant Transform.VALUE_NOT_SET. If the attributes remain unchanged then the layout information will not be encoded. If any of the values in this group are set then they must all have values assigned for the field to be displayed correctly otherwise default values of 0 will be used.

HTML Support
Setting the HTML flag to true allows text marked up with a limited set of HTML tags to be displayed in the text field. The following tags are supported:

<p></p> Delimits a paragraph. Only the align attribute is supported:

<br> Inserts a line break.>

<a></a> Define a hyperlink. Two attributes are supported:
  • href - the URL of the link.
  • target - name of a window or frame. (optional)
<font></font> Format enclosed text using the font. Three attributes are supported:
  • name - must match the name of a font defined using the FSDefineFont2 class.
  • size - the height of the font in points (not twips).
  • color - the colour of the text in the hexadecimal format #RRGGBB.
<b></b> Delimits text that should be displayed in bold.
<i></i> Delimits text that should be displayed in italics.
<u></u> Delimits text that should be displayed underlined.
<li></li> Display bulleted paragraph. Strictly speaking this is not an HTML list. The <ul> tag is not required and no other list format is supported.

History

FSDefineTextField class represents the DefineTextField from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 4.


Field Summary
static int AlignCenter
          Defines that the text displayed in a text field is centre aligned.
static int AlignJustify
          Defines that the text displayed in a text field is justified.
static int AlignLeft
          Defines that the text displayed in a text field is left aligned.
static int AlignRight
          Defines that the text displayed in a text field is right aligned.
static java.lang.String AutoSize
          Key used to identify the autoSize attribute.
static java.lang.String Bordered
          Key used to identify the bordered attribute.
static java.lang.String Color
          Key used to identify the color attribute.
static java.lang.String FontHeight
          Key used to identify the fontHeight attribute.
static java.lang.String FontIdentifier
          Key used to identify the identifier attribute.
static java.lang.String HTML
          Key used to identify the bordered attribute.
static java.lang.String Indent
          Key used to identify the indent attribute.
static java.lang.String InitialText
          Key used to identify the initialText attribute.
static java.lang.String Leading
          Key used to identify the leading attribute.
static java.lang.String LeftMargin
          Key used to identify the leftMargin attribute.
static java.lang.String MaxLength
          Key used to identify the maxLength attribute.
static java.lang.String Multiline
          Key used to identify the multiline attribute.
static java.lang.String Password
          Key used to identify the password attribute.
static java.lang.String ReadOnly
          Key used to identify the readOnly attribute.
static java.lang.String RightMargin
          Key used to identify the rightMargin attribute.
static java.lang.String Selectable
          Key used to identify the selectable attribute.
static java.lang.String UseFontGlyphs
          Key used to identify the useFontGlyphs attribute.
static java.lang.String VariableName
          Key used to identify the variableName attribute.
static java.lang.String WordWrapped
          Key used to identify the wordWrapped attribute.
 
Fields inherited from class com.flagstone.transform.FSDefineObject
identifier
 
Fields inherited from class com.flagstone.transform.FSMovieObject
ButtonColorTransform, ButtonSound, DefineBitsPtr, DefineButton, DefineButton2, DefineFont, DefineFont2, DefineImage, DefineImage2, DefineJPEGImage, DefineJPEGImage2, DefineJPEGImage3, DefineMorphShape, DefineMovieClip, DefineShape, DefineShape2, DefineShape3, DefineSound, DefineText, DefineText2, DefineTextField, DefineVideo, DoAction, EnableDebugger, EnableDebugger2, Export, extendLength, FontInfo, FontInfo2, FrameLabel, Free, Import, Initialize, JPEGTables, length, LimitScript, PathsArePostscript, PlaceObject, PlaceObject2, Protect, QuicktimeMovie, RemoveObject, RemoveObject2, SerialNumber, SetBackgroundColor, ShowFrame, SoundStreamBlock, SoundStreamHead, SoundStreamHead2, StartSound, TabOrder, type, VideoFrame
 
Constructor Summary
FSDefineTextField(FSCoder coder)
          Construct an FSDefineTextField object, initialising it with values decoded from an encoded object.
FSDefineTextField(FSDefineTextField obj)
          Constructs an FSDefineText object by copying values from an existing object.
FSDefineTextField(int anIdentifier, FSBounds aBounds)
          Constructs an FSDefineTextField object with the specified identifier and with the size defined by the bounding rectangle.
FSDefineTextField(int anIdentifier, FSBounds aBounds, java.util.Hashtable attributes)
          Constructs an FSDefineTextField object setting the attributes added to the Hashtable.
 
Method Summary
 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.
 int getAlignment()
          Gets the alignment of the text, either AlignLeft, AlignRight, AlignCenter or AlignJustify.
 java.util.Hashtable getAttributes()
          Gets the list of attributes for the object.
 FSBounds getBounds()
          Gets the bounding rectangle that completely encloses the text field.
 FSColor getColor()
          Gets the text color.
 int getFontHeight()
          Gets the height of the characters.
 int getFontIdentifier()
          Gets the identifier of the font used to display the characters.
 int getIndent()
          Gets the indentation of the first line of text in twips.
 java.lang.String getInitialText()
          Gets the default text displayed in the field.
 int getLeading()
          Gets the leading in twips.
 int getLeftMargin()
          Gets the left margin in twips.
 int getMaxLength()
          Gets the maximum length of the text displayed.
 int getRightMargin()
          Gets the right margin in twips.
 java.lang.String getVariableName()
          Gets the name of the variable the value in the text field will be assigned to.
 boolean isAutoSize()
          Does the text field resize to fit the contents.
 boolean isBordered()
          Is the text field bordered.
 boolean isHTML()
          Does the text field contain HTML.
 boolean isMultiline()
          Does the text field support multiple lines of text.
 boolean isPassword()
          Does the text field protect passwords being entered.
 boolean isReadOnly()
          Is the text field read-only.
 boolean isSelectable()
          Is the text field selectable.
 boolean isWordWrapped()
          Does the text field support word wrapping.
 int length(FSCoder coder)
           
 void setAlignment(int aType)
          Sets the alignment of the text, either AlignLeft, AlignRight, AlignCenter or AlignJustify.
 void setAttributes(java.util.Hashtable attributes)
          Sets the attributes for the object.
 void setAutoSize(boolean aFlag)
          Sets whether the text field will resize to fit the contents.
 void setBordered(boolean aFlag)
          Set whether the text field is bordered.
 void setBounds(FSBounds aBounds)
          Sets the bounding rectangle of the text field.
 void setColor(FSColor aColor)
          Sets the text color.
 void setFontHeight(int aNumber)
          Sets the height of the characters.
 void setFontIdentifier(int anIdentifier)
          Sets the identifier of the font used to display the characters.
 void setHTML(boolean aFlag)
          Set whether the text field contains HTML.
 void setIndent(int aNumber)
          Gets the indentation of the first line of text in twips.
 void setInitialText(java.lang.String aString)
          Sets the value that will initially be displayed in the text field.
 void setLeading(int aNumber)
          Sets the leading in twips.
 void setLeftMargin(int aNumber)
          Sets the left margin in twips.
 void setMaxLength(int aNumber)
          Sets the maximum length of the text displayed.
 void setMultiline(boolean aFlag)
          Set whether the text field contains multiple lines of text.
 void setPassword(boolean aFlag)
          Set whether the text field should protect passwords entered.
 void setReadOnly(boolean aFlag)
          Set whether the text field is read-only.
 void setRightMargin(int aNumber)
          Sets the right margin in twips.
 void setSelectable(boolean aFlag)
          Set whether the text field is selectable.
 void setUseFontGlyphs(boolean aFlag)
          Set whether the text field characters are displayed using the font defined in the movie or whether the Flash Player uses a font definition loaded from the platform on which it is hosted.
 void setVariableName(java.lang.String aString)
          Sets the name of the variable the value in the text field will be assigned to.
 void setWordWrapped(boolean aFlag)
          Set whether the text field supports word wrapping.
 boolean useFontGlyphs()
          Indicates whether the test will be displayed using the font defined in the movie or whether a font defined on the host platform will be used.
 
Methods inherited from class com.flagstone.transform.FSDefineObject
getIdentifier, setIdentifier
 
Methods inherited from class com.flagstone.transform.FSMovieObject
getType
 
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

WordWrapped

public static final java.lang.String WordWrapped
Key used to identify the wordWrapped attribute.

See Also:
Constant Field Values

Multiline

public static final java.lang.String Multiline
Key used to identify the multiline attribute.

See Also:
Constant Field Values

Password

public static final java.lang.String Password
Key used to identify the password attribute.

See Also:
Constant Field Values

ReadOnly

public static final java.lang.String ReadOnly
Key used to identify the readOnly attribute.

See Also:
Constant Field Values

Selectable

public static final java.lang.String Selectable
Key used to identify the selectable attribute.

See Also:
Constant Field Values

Bordered

public static final java.lang.String Bordered
Key used to identify the bordered attribute.

See Also:
Constant Field Values

HTML

public static final java.lang.String HTML
Key used to identify the bordered attribute.

See Also:
Constant Field Values

UseFontGlyphs

public static final java.lang.String UseFontGlyphs
Key used to identify the useFontGlyphs attribute.

See Also:
Constant Field Values

AutoSize

public static final java.lang.String AutoSize
Key used to identify the autoSize attribute.

See Also:
Constant Field Values

FontIdentifier

public static final java.lang.String FontIdentifier
Key used to identify the identifier attribute.

See Also:
Constant Field Values

FontHeight

public static final java.lang.String FontHeight
Key used to identify the fontHeight attribute.

See Also:
Constant Field Values

Color

public static final java.lang.String Color
Key used to identify the color attribute.

See Also:
Constant Field Values

MaxLength

public static final java.lang.String MaxLength
Key used to identify the maxLength attribute.

See Also:
Constant Field Values

LeftMargin

public static final java.lang.String LeftMargin
Key used to identify the leftMargin attribute.

See Also:
Constant Field Values

RightMargin

public static final java.lang.String RightMargin
Key used to identify the rightMargin attribute.

See Also:
Constant Field Values

Indent

public static final java.lang.String Indent
Key used to identify the indent attribute.

See Also:
Constant Field Values

Leading

public static final java.lang.String Leading
Key used to identify the leading attribute.

See Also:
Constant Field Values

VariableName

public static final java.lang.String VariableName
Key used to identify the variableName attribute.

See Also:
Constant Field Values

InitialText

public static final java.lang.String InitialText
Key used to identify the initialText attribute.

See Also:
Constant Field Values

AlignLeft

public static final int AlignLeft
Defines that the text displayed in a text field is left aligned.

See Also:
Constant Field Values

AlignRight

public static final int AlignRight
Defines that the text displayed in a text field is right aligned.

See Also:
Constant Field Values

AlignCenter

public static final int AlignCenter
Defines that the text displayed in a text field is centre aligned.

See Also:
Constant Field Values

AlignJustify

public static final int AlignJustify
Defines that the text displayed in a text field is justified.

See Also:
Constant Field Values
Constructor Detail

FSDefineTextField

public FSDefineTextField(FSCoder coder)
Construct an FSDefineTextField object, initialising it with values decoded from an encoded object.

Parameters:
coder - an FSCoder containing the binary data.

FSDefineTextField

public FSDefineTextField(int anIdentifier,
                         FSBounds aBounds)
Constructs an FSDefineTextField object with the specified identifier and with the size defined by the bounding rectangle. All other attributes are set to their default values which will result in a blank, single-line, editable text field. Any values entered will not be assigned to a variable. Since no font is specified the text will be displayed in a non-spaced font 20 twips in height.

Parameters:
anIdentifier - the unique identifier for this object.
aBounds - the bounding rectangle for the field which defines its size.

FSDefineTextField

public FSDefineTextField(int anIdentifier,
                         FSBounds aBounds,
                         java.util.Hashtable attributes)
Constructs an FSDefineTextField object setting the attributes added to the Hashtable. Each entry consists of a key-value pair. The key is one of the pre-defined attribute names while the value is an instance of a wrapper class (Boolean, Integer or String) that will be assigned to the specified attribute.

Parameters:
anIdentifier - the unique identifier for this object.
aBounds - the bounding rectangle for the field which defines its size.
attributes - a collection of key-value pairs identifying the attributes to be set.

FSDefineTextField

public FSDefineTextField(FSDefineTextField obj)
Constructs an FSDefineText object by copying values from an existing object.

Parameters:
obj - an FSDefineText object.
Method Detail

getBounds

public FSBounds getBounds()
Gets the bounding rectangle that completely encloses the text field.

Returns:
the bounding rectangle for the text field.

isWordWrapped

public boolean isWordWrapped()
Does the text field support word wrapping.

Returns:
a flag indicating whether the text in the field will be wrapped.

isMultiline

public boolean isMultiline()
Does the text field support multiple lines of text.

Returns:
a flag indicating whether the text in the field will contain multiple lines.

isPassword

public boolean isPassword()
Does the text field protect passwords being entered.

Returns:
a flag indicating whether the text in the field represents a password.

isReadOnly

public boolean isReadOnly()
Is the text field read-only.

Returns:
a flag indicating whether the text in the field is read-only.

isSelectable

public boolean isSelectable()
Is the text field selectable.

Returns:
a flag indicating whether the text in the field is selectable.

isBordered

public boolean isBordered()
Is the text field bordered.

Returns:
a flag indicating whether the text in the field is bordered.

isHTML

public boolean isHTML()
Does the text field contain HTML.

Returns:
a flag indicating whether the text in the field contains HTML.

isAutoSize

public boolean isAutoSize()
Does the text field resize to fit the contents.

Returns:
a flag indicating whether the text field will resize automatically.

setAutoSize

public void setAutoSize(boolean aFlag)
Sets whether the text field will resize to fit the contents.

Parameters:
aFlag - indicate whether the text field will resize automatically.

useFontGlyphs

public boolean useFontGlyphs()
Indicates whether the test will be displayed using the font defined in the movie or whether a font defined on the host platform will be used.

Returns:
true if the text will be displayed using the glyphs from the font defined in the movie, false if the glyphs will be loaded from the platform on which the Flash Player is hosted.

getFontIdentifier

public int getFontIdentifier()
Gets the identifier of the font used to display the characters.

Returns:
the font identifier.

getFontHeight

public int getFontHeight()
Gets the height of the characters.

Returns:
the height of the font.

getColor

public FSColor getColor()
Gets the text color.

Returns:
the color of the text.

getMaxLength

public int getMaxLength()
Gets the maximum length of the text displayed.

Returns:
the maximum number of characters displayed.

getAlignment

public int getAlignment()
Gets the alignment of the text, either AlignLeft, AlignRight, AlignCenter or AlignJustify.

Returns:
the alignment code.

getLeftMargin

public int getLeftMargin()
Gets the left margin in twips.

Returns:
the left margin.

getRightMargin

public int getRightMargin()
Gets the right margin in twips.

Returns:
the right margin.

getIndent

public int getIndent()
Gets the indentation of the first line of text in twips.

Returns:
the indentation of the first line.

getLeading

public int getLeading()
Gets the leading in twips.

Returns:
the leading.

getVariableName

public java.lang.String getVariableName()
Gets the name of the variable the value in the text field will be assigned to.

Returns:
the name of the variable.

getInitialText

public java.lang.String getInitialText()
Gets the default text displayed in the field.

Returns:
the default value displayed in the field.

getAttributes

public java.util.Hashtable getAttributes()
Gets the list of attributes for the object. The Hashtable contains a list of key-value pairs. The key is one of the pre-defined attribute names while the value is an instance of a wrapper class (Boolean, Integer or String) that contains the corresponding object attribute.

Returns:
the list of attributes for the object.

setBounds

public void setBounds(FSBounds aBounds)
Sets the bounding rectangle of the text field.

Parameters:
aBounds - the bounding rectangle enclosing the text field.

setWordWrapped

public void setWordWrapped(boolean aFlag)
Set whether the text field supports word wrapping.

Parameters:
aFlag - set whether the text field is word wrapped.

setMultiline

public void setMultiline(boolean aFlag)
Set whether the text field contains multiple lines of text.

Parameters:
aFlag - set whether the text field is multiline.

setPassword

public void setPassword(boolean aFlag)
Set whether the text field should protect passwords entered.

Parameters:
aFlag - set whether the text field is password protected.

setReadOnly

public void setReadOnly(boolean aFlag)
Set whether the text field is read-only.

Parameters:
aFlag - set whether the text field is read-only.

setSelectable

public void setSelectable(boolean aFlag)
Set whether the text field is selectable.

Parameters:
aFlag - set whether the text field is selectable.

setBordered

public void setBordered(boolean aFlag)
Set whether the text field is bordered.

Parameters:
aFlag - set whether the text field is bordered.

setHTML

public void setHTML(boolean aFlag)
Set whether the text field contains HTML.

Parameters:
aFlag - set whether the text field contains HTML.

setUseFontGlyphs

public void setUseFontGlyphs(boolean aFlag)
Set whether the text field characters are displayed using the font defined in the movie or whether the Flash Player uses a font definition loaded from the platform on which it is hosted.

Parameters:
aFlag - set whether the text field characters will be drawn using the font in the movie (true) or use a font loaded by the Flash Player (false).

setFontIdentifier

public void setFontIdentifier(int anIdentifier)
Sets the identifier of the font used to display the characters.

Parameters:
anIdentifier - the identifier for the font that the text will be rendered in.

setFontHeight

public void setFontHeight(int aNumber)
Sets the height of the characters.

Parameters:
aNumber - the height of the font.

setColor

public void setColor(FSColor aColor)
Sets the text color. If set to null then the text color defaults to black.

Parameters:
aColor - the colour object that defines the text colour.

setMaxLength

public void setMaxLength(int aNumber)
Sets the maximum length of the text displayed. May be set to zero if no maximum length is defined.

Parameters:
aNumber - the maximum number of characters displayed in the field.

setAlignment

public void setAlignment(int aType)
Sets the alignment of the text, either AlignLeft, AlignRight, AlignCenter or AlignJustify.

Parameters:
aType - the type of alignment.

setLeftMargin

public void setLeftMargin(int aNumber)
Sets the left margin in twips.

Parameters:
aNumber - the width of the left margin.

setRightMargin

public void setRightMargin(int aNumber)
Sets the right margin in twips.

Parameters:
aNumber - the width of the right margin.

setIndent

public void setIndent(int aNumber)
Gets the indentation of the first line of text in twips.

Parameters:
aNumber - the indentation for the first line.

setLeading

public void setLeading(int aNumber)
Sets the leading in twips.

Parameters:
aNumber - the value for the leading.

setVariableName

public void setVariableName(java.lang.String aString)
Sets the name of the variable the value in the text field will be assigned to.

Parameters:
aString - the name of the variable.

setInitialText

public void setInitialText(java.lang.String aString)
Sets the value that will initially be displayed in the text field.

Parameters:
aString - the initial text displayed.

setAttributes

public void setAttributes(java.util.Hashtable attributes)
Sets the attributes for the object. The Hashtable contains a list of key-value pairs. The key is one of the pre-defined attribute names while the value is an instance of a wrapper class (Boolean, Integer or String) that will be assigned to the specified attribute.

Parameters:
attributes - the list of attributes for the object.

clone

public java.lang.Object clone()
Description copied from class: FSTransformObject
Creates a deep copy of the entire object.

Overrides:
clone in class FSTransformObject
Returns:
a copy of the object.

equals

public boolean equals(java.lang.Object anObject)
Description copied from class: FSMovieObject
Returns true if anObject is equal to this one. Objects are considered equal if they would generate identical binary data when they are encoded to a Flash file.

Overrides:
equals in class FSMovieObject
Returns:
true if this object would be identical to anObject when encoded.

appendDescription

public void appendDescription(java.lang.StringBuffer buffer,
                              int depth)
Description copied from class: FSTransformObject
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. This method provide a more controlled way of creating a string representation of an object since large objects such as font or shape definitions can contain dozens of nested objects. The representation of the object is appended to the StringBuffer, showing the name of the class and values of the attributes it contains. If the object contains any attributes that are objects then the object graph will be traversed up to the specified depth. If objects are nested at a level less than specified depth then the full string representation of the object is displayed. For objects at the specified depth only the name of the class is displayed. Any objects below this depth are not displayed.

Overrides:
appendDescription in class FSDefineObject
Parameters:
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.

length

public int length(FSCoder coder)
Overrides:
length in class FSDefineObject

encode

public void encode(FSCoder coder)
Overrides:
encode in class FSDefineObject

decode

public void decode(FSCoder coder)
Overrides:
decode in class FSDefineObject