com.flagstone.transform.text
Class DefineTextField

java.lang.Object
  extended by com.flagstone.transform.text.DefineTextField
All Implemented Interfaces:
Copyable<MovieTag>, SWFEncodeable, DefineTag, MovieTag

public final class DefineTextField
extends Object
implements DefineTag

DefineTextField 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:

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.
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.
maxLength The maximum length of the text field. May be set to zero is not maximum length is defined.

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 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.

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 DefineFont2 class.
  • size - the height of the font in twips.
  • color - the colour of the text in the hexadecimal format #RRGGBB.
<b></b> Delimits text that should be displayed in bold.
<b></b> Delimits text that should be displayed in italics.
<b></b> 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 list formats are supported.


Constructor Summary
DefineTextField(DefineTextField object)
          Creates and initialises a DefineTextField object using the values copied from another DefineTextField object.
DefineTextField(int uid)
          Creates an DefineTextField object with the specified identifier.
DefineTextField(SWFDecoder coder, Context context)
          Creates and initialises a DefineTextField object using values encoded in the Flash binary format.
 
Method Summary
 DefineTextField copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 HorizontalAlign getAlignment()
          Get the alignment of the text, either AlignLeft, AlignRight, AlignCenter or AlignJustify.
 Bounds getBounds()
          Returns the bounding rectangle that completely encloses the text field.
 Color getColor()
          Get the text color.
 String getFontClass()
          Get the name of the Actionscript 3 class that provides the font.
 int getFontHeight()
          Get the size of the font used to display the text.
 int getFontIdentifier()
          Get the identifier of the font used to display the characters.
 int getIdentifier()
          Get the unique identifier assigned to this object.
 int getIndent()
          Get the indentation of the first line of text in twips.
 String getInitialText()
          Get the default text displayed in the field.
 int getLeading()
          Get the leading in twips.
 int getLeftMargin()
          Get the left margin in twips.
 int getMaxLength()
          Get the maximum number of characters displayed in the field.
 int getRightMargin()
          Get the right margin in twips.
 String getVariableName()
          Get 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 isEmbedded()
          Indicates whether the text will be displayed using the font defined in the movie or whether a font defined on the host platform will be used.
 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 prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 DefineTextField setAlignment(HorizontalAlign align)
          Sets the alignment of the text, either AlignLeft, AlignRight, AlignCenter or AlignJustify.
 DefineTextField setAutoSize(boolean aFlag)
          Sets whether the text field will resize to fit the contents.
 DefineTextField setBordered(boolean aFlag)
          Set whether the text field is bordered.
 DefineTextField setBounds(Bounds rect)
          Sets the bounding rectangle of the text field.
 DefineTextField setColor(Color aColor)
          Sets the text color.
 DefineTextField setEmbedded(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.
 DefineTextField setFontClass(String name)
          Set the name of the Actionscript 3 class that provides the font.
 DefineTextField setFontHeight(int aNumber)
          Sets the height of the characters.
 DefineTextField setFontIdentifier(int uid)
          Sets the identifier of the font used to display the characters.
 DefineTextField setHtml(boolean aFlag)
          Set whether the text field contains HTML.
 void setIdentifier(int uid)
          Sets the unique identifier for an object within a given Movie.
 DefineTextField setIndent(Integer aNumber)
          Returns the indentation of the first line of text in twips.
 DefineTextField setInitialText(String aString)
          Sets the value that will initially be displayed in the text field.
 DefineTextField setLeading(Integer aNumber)
          Sets the spacing between lines, measured in twips.
 DefineTextField setLeftMargin(Integer aNumber)
          Sets the left margin in twips.
 DefineTextField setMaxLength(int aNumber)
          Sets the maximum length of the text displayed.
 DefineTextField setMultiline(boolean aFlag)
          Set whether the text field contains multiple lines of text.
 DefineTextField setPassword(boolean aFlag)
          Set whether the text field should protect passwords entered.
 DefineTextField setReadOnly(boolean aFlag)
          Set whether the text field is read-only.
 DefineTextField setRightMargin(Integer aNumber)
          Sets the right margin in twips.
 DefineTextField setSelectable(boolean aFlag)
          Set whether the text field is selectable.
 DefineTextField setVariableName(String aString)
          Sets the name of the variable the value in the text field will be assigned to.
 DefineTextField setWordWrapped(boolean aFlag)
          Set whether the text field supports word wrapping.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefineTextField

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

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
context - a Context object used to manage the decoders for different type of object and to pass information on how objects are decoded.
Throws:
IOException - if an error occurs while decoding the data.

DefineTextField

public DefineTextField(int uid)
Creates an DefineTextField object with the specified identifier.

Parameters:
uid - the unique identifier for the text field.

DefineTextField

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

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

getIdentifier

public int getIdentifier()
Get the unique identifier assigned to this object.

Specified by:
getIdentifier in interface DefineTag
Returns:
the unique identifier used by the Flash Player to reference this definition.

setIdentifier

public void setIdentifier(int uid)
Sets the unique identifier for an object within a given Movie.

Specified by:
setIdentifier in interface DefineTag
Parameters:
uid - a unique identifier for the object. Must be in the range 1..65535.

getBounds

public Bounds getBounds()
Returns the bounding rectangle that completely encloses the text field.

Returns:
the bounding rectangle of the text.

isWordWrapped

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

Returns:
true if the field will wrap the text.

isMultiline

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

Returns:
true if the field contains more than one line.

isPassword

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

Returns:
true if the field obscures the characters typed.

isReadOnly

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

Returns:
true if the text cannot be edited.

isSelectable

public boolean isSelectable()
Is the text field selectable.

Returns:
true if the text can be selected with the mouse.

isBordered

public boolean isBordered()
Is the text field bordered.

Returns:
true if the field has a border.

isHtml

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

Returns:
true if the field displays HTML.

isAutoSize

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

Returns:
true if the field will automatically resize to fit the text.

setAutoSize

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

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

isEmbedded

public boolean isEmbedded()
Indicates whether the text 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()
Get the identifier of the font used to display the characters.

Returns:
the unique identifier of the font.

getFontClass

public String getFontClass()
Get the name of the Actionscript 3 class that provides the font.

Returns:
the name the Actionscript class.

getFontHeight

public int getFontHeight()
Get the size of the font used to display the text.

Returns:
the height of the font in twips.

getColor

public Color getColor()
Get the text color.

Returns:
the colour used to display the text.

getMaxLength

public int getMaxLength()
Get the maximum number of characters displayed in the field.

Returns:
the maximum number of characters displayed.

getAlignment

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

Returns:
the alignment of the text.

getLeftMargin

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

Returns:
the padding between the text and the left edge of the field.

getRightMargin

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

Returns:
the padding between the text and the right edge of the field.

getIndent

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

Returns:
the initial indent for the first line of text.

getLeading

public int getLeading()
Get the leading in twips.

Returns:
the spacing between lines.

getVariableName

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

Returns:
the name of the actionscript variable that the field contents are assigned to.

getInitialText

public String getInitialText()
Get the default text displayed in the field.

Returns:
the sting initially displayed in the field.

setBounds

public DefineTextField setBounds(Bounds rect)
Sets the bounding rectangle of the text field.

Parameters:
rect - the bounding rectangle enclosing the text field. Must not be null.
Returns:
this object.

setWordWrapped

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

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

setMultiline

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

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

setPassword

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

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

setReadOnly

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

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

setSelectable

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

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

setBordered

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

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

setHtml

public DefineTextField setHtml(boolean aFlag)
Set whether the text field contains HTML.

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

setEmbedded

public DefineTextField setEmbedded(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).
Returns:
this object.

setFontIdentifier

public DefineTextField setFontIdentifier(int uid)
Sets the identifier of the font used to display the characters.

Parameters:
uid - the identifier for the font that the text will be rendered in. Must be in the range 1..65535.
Returns:
this object.

setFontClass

public DefineTextField setFontClass(String name)
Set the name of the Actionscript 3 class that provides the font.

Parameters:
name - the name the Actionscript class.
Returns:
this object.

setFontHeight

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

Parameters:
aNumber - the height of the font. Must be in the range 0..65535.
Returns:
this object.

setColor

public DefineTextField setColor(Color 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.
Returns:
this object.

setMaxLength

public DefineTextField 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. Must be in the range 0..65535.
Returns:
this object.

setAlignment

public DefineTextField setAlignment(HorizontalAlign align)
Sets the alignment of the text, either AlignLeft, AlignRight, AlignCenter or AlignJustify.

Parameters:
align - the type of alignment. Must be either ALIGN_LEFT, ALIGN_RIGHT or ALIGN_JUSTIFY.
Returns:
this object.

setLeftMargin

public DefineTextField setLeftMargin(Integer aNumber)
Sets the left margin in twips.

Parameters:
aNumber - the width of the left margin. Must be in the range 0..65535.
Returns:
this object.

setRightMargin

public DefineTextField setRightMargin(Integer aNumber)
Sets the right margin in twips.

Parameters:
aNumber - the width of the right margin. Must be in the range 0..65535.
Returns:
this object.

setIndent

public DefineTextField setIndent(Integer aNumber)
Returns the indentation of the first line of text in twips.

Parameters:
aNumber - the indentation for the first line. Must be in the range 0..65535.
Returns:
this object.

setLeading

public DefineTextField setLeading(Integer aNumber)
Sets the spacing between lines, measured in twips.

Parameters:
aNumber - the value for the leading. Must be in the range -32768..32767.
Returns:
this object.

setVariableName

public DefineTextField setVariableName(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.
Returns:
this object.

setInitialText

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

Parameters:
aString - the initial text displayed.
Returns:
this object.

copy

public DefineTextField 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.