package ch12_1
{
import flash.display.MovieClip;
import flash.events.ContextMenuEvent;
import flash.text.*;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.system.System;
public class IHavaADream extends MovieClip
{
var tf:TextField = new TextField();
public function IHavaADream()
{
stage.focus =tf;
tf.autoSize ="left";
tf.wordWrap =true;
tf.multiline =true;
tf.width =550;
tf.htmlText ="<font size ='20'> Snow flows over a quiet village;\n" +
" 静静的村庄飘着白的雪\n" +
" Doves fly across a gloomy sky." +
"</font>";
tf.type =TextFieldType.INPUT;
addChild(tf);
var menu:ContextMenu = new ContextMenu();
var cu:ContextMenuItem = new ContextMenuItem("复制本行");
menu.customItems =[cu];
tf.contextMenu =menu;
cu.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,clearClip);
}
private function clearClip(e:ContextMenuEvent):void
{
System.setClipboard(tf.getLineText(tf.getLineIndexAtPoint(mouseX,mouseY)));//复制本行
}
}
}