Yasuhiro Sasama > SWF-Builder-0.16 > SWF::Builder::Character::EditText

Download:
SWF-Builder-0.16.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.02   Source  

NAME ^

SWF::Builder::Character::EditText - SWF dynamic editable text object

SYNOPSIS ^

  my $text = $mc->new_dynamic_text( $font )
    ->size(10)
    ->color('000000')
    ->text('This is a text.');

  my $text_i = $text->place;

  my $field = $mc->new_input_field;
  $field->place;

DESCRIPTION ^

This module creates dynamic editable text objects, which can be changed at playing time.

Basic dynamic editable text object

$etext = $mc->new_edit_text( [$font, $text] )

returns a new basic dynamic editable text object. It has interfaces to raw DefineEditText tag. $font is an SWF::Builder::Font object.

$etext->font( $font )

applies the font to the text. $font is an SWF::Builder::Font object. Unlike static text, the font is applied to the whole text. If the text will be changed in the playing time, you should add glyph data of all characters which will be used to the font by $font->add_glyph or turn off the embed flag of the font.

$etext->size( $size )

sets a font size to $size in pixel. Unlike static text, the font size of the whole text is changed.

$etext->color( $color )

sets color of the text. The color can take a six or eight-figure hexadecimal string, an array reference of R, G, B, and optional alpha value, an array reference of named parameters such as [Red => 255], and SWF::Element::RGB/RGBA object. Unlike static text, the color is applied to the whole text.

$etext->text( $string )

writes the $string.

$etext->leading( $leading )

sets the vertical distance between the lines in pixel.

$etext->box_size( $width, $height )

sets the bounding box of the text and stops auto-sizing the box. When either $width or $height is undef, it is unchanged. Fixing bounding box may cause unexpected text clipping. You should set DefineEditText flag Multiline and/or WordWrap. See SWF::Element.

$etext->draw_border

draws the border.

$etext->align( 'left' / 'right' / 'center' / 'justify' )

sets the text alignment.

$etext->methos for SWF::Element::Tag::DefineEditText

You can control details of the texts to call methods for DefineEditText tag. See SWF::Element.

Preset dynamic text object

The following objects are inheritants of the basic dynamic editable text. These are preset some proper flags of DefineEditText tag.

$dtext = $mc->new_dynamic_text( [$font, $text] )

returns a new dynamic text. It is read-only, multiline text enabled, and auto-sized its bounding box.

$htmltext = $mc->new_html_text( [$html] )

returns a new HTML text. It is read-only, multiline text enabled, and auto-sized its bounding box. The text is treated as a subset of HTML. Supported tags are <a>, <b>, <br>, <font>, <i>, <img>, <li>, <p>, <span>, <u>, and two special tags, <tab> and <textformat>. See Macromedia Flash File Format Specification and ActionScript Reference Guide for further information.

$htmltext->use_font( $font, ... )

tells $htmltext what fonts are used in the HTML. In general, upright, italic, bold, and bold italic font are in the different TrueType font files. You should prepare 2-4 fonts if you use <b> and <i> tags, like this:

 my $fp = $ENV{SYSTEMROOT}.'/fonts';  # for Windows.
 my $font = $m->new_font("$fp/arial.ttf");
 $font->add_glyph('a', 'z');
 my $fonti = $m->new_font("$fp/ariali.ttf");
 $fonti->add_glyph('a', 'z');
 my $ht = $m->new_html_text;
 $ht->text('<font face="arial">test <i>string</i></font>');
 $ht->use_font($font, $fonti);
$mc->new_text_area( $width, $height )

returns a new editable text area. It takes area width and height in pixel.

$mc->new_input_field( [$length] )

returns a new one-line input field. $length is a max length of input string.

$mc->new_password_field( [$length] )

returns a new one-line password field. $length is a max length of input string.

COPYRIGHT ^

Copyright 2004 Yasuhiro Sasama (ySas), <ysas@nmt.ne.jp>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: