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.

Vous pouvez utiliser la métho<strong>de</strong> replaceSel() pour insérer et effacer <strong>du</strong> texte sans perturber<br />

la mise en forme <strong>de</strong>s caractères et <strong>du</strong> paragraphe <strong>du</strong> reste <strong>du</strong> texte.<br />

Vous <strong>de</strong>vez utiliser Selection.setFocus() pour choisir le champ avant <strong>de</strong> transmettre cette<br />

comman<strong>de</strong>.<br />

Disponibilité : <strong>ActionScript</strong> 1.0 ; Flash Player 6<br />

Paramètres<br />

newText:String - Chaîne.<br />

Exemple<br />

L'exemple <strong>de</strong> co<strong>de</strong> suivant crée un champ texte multiligne avec <strong>du</strong> texte figurant sur la Scène.<br />

Lorsque vous sélectionnez <strong>du</strong> texte, puis cliquez <strong>du</strong> bouton droit <strong>de</strong> la souris ou effectuez un<br />

Contrôle-clic sur ce champ, vous pouvez sélectionner Enter current date dans le menu<br />

contextuel. Cette sélection appelle une fonction qui remplace le texte sélectionné par la date<br />

actuelle.<br />

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

240);<br />

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

my_txt.wordWrap = true;<br />

my_txt.multiline = true;<br />

my_txt.type = "input";<br />

my_txt.text = "Select some sample text from the text field and then rightclick/control<br />

click "<br />

+ "and select 'Enter current date' from the context menu to replace the<br />

"<br />

+ "currently selected text with the current date.";<br />

var my_cm:ContextMenu = new ContextMenu();<br />

my_cm.customItems.push(new ContextMenuItem("Enter current date",<br />

enterDate));<br />

function enterDate(obj:Object, menuItem:ContextMenuItem) {<br />

var today_str:String = new Date().toString();<br />

var date_str:String = today_str.split(" ", 3).join(" ");<br />

my_txt.replaceSel(date_str);<br />

}<br />

my_txt.menu = my_cm;<br />

La métho<strong>de</strong> MovieClip.getNextHighestDepth() utilisée dans cet exemple requiert Flash<br />

Player 7 ou version ultérieure. Si votre fichier SWF comporte un composant <strong>de</strong> la version 2,<br />

utilisez la classe DepthManager <strong>de</strong>s composants <strong>de</strong> la version 2 au lieu <strong>de</strong> la métho<strong>de</strong><br />

MovieClip.getNextHighestDepth().<br />

TextField 1245

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

Saved successfully!

Ooh no, something went wrong!