03.07.2013 Views

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

width:Number [facultatif] - Nombre indiquant la largeur, en pixels, à laquelle le texte spécifié<br />

doit effectuer un retour à la ligne automatique.<br />

Valeur renvoyée<br />

Object - Objet avec les propriétés width, height, ascent, <strong>de</strong>scent, textFieldHeight,<br />

textFieldWidth.<br />

Exemple<br />

Cet exemple crée un champ texte d'une seule ligne <strong>de</strong> taille tout juste suffisante pour afficher<br />

une chaîne <strong>de</strong> texte avec la mise en format spécifiée.<br />

var my_str:String = "Small string";<br />

// Create a TextFormat object,<br />

// and apply its properties.<br />

var my_fmt:TextFormat = new TextFormat();<br />

with (my_fmt) {<br />

font = "Arial";<br />

bold = true;<br />

}<br />

// Obtain metrics information for the text string<br />

// with the specified formatting.<br />

var metrics:Object = my_fmt.getTextExtent(my_str);<br />

// Create a text field just large enough to display the text.<br />

this.createTextField("my_txt", this.getNextHighestDepth(), 100, 100,<br />

metrics.textFieldWidth,<br />

metrics.textFieldHeight);<br />

my_txt.bor<strong>de</strong>r = true;<br />

my_txt.wordWrap = true;<br />

// Assign the same text string and TextFormat object to the my_txt object.<br />

my_txt.text = my_str;<br />

my_txt.setTextFormat(my_fmt);<br />

L'exemple suivant crée un champ texte multiligne d'une largeur <strong>de</strong> 100 pixels et d'une<br />

hauteur suffisante pour afficher une chaîne avec la mise en format spécifiée.<br />

// Create a TextFormat object.<br />

var my_fmt:TextFormat = new TextFormat();<br />

// Specify formatting properties for the TextFormat object:<br />

my_fmt.font = "Arial";<br />

my_fmt.bold = true;<br />

my_fmt.leading = 4;<br />

// The string of text to be displayed<br />

var textToDisplay:String = "Macromedia Flash Player 7, now with improved<br />

text metrics.";<br />

1280 Chapitre 2: Classes <strong>ActionScript</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!