<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initData();"
>
<!--mx:Style>
@font-face {
src: local("MS ゴシック");
fontFamily: MSG;
fontWeight: normal;
}
TextArea {
font-family: MSG;
fontSize: 16px;
}
</mx:Style-->
<mx:Script>
<![CDATA[
import mx.controls.*;
import mx.events.*;
// アプリケーションの初期化
public function initData():void {
txt_01.text = "A\nB\nCCCCCCCCCCCCCCCCCCCCCCCC\nD\nE\nF\nG\nH\n";
txt_02.text = "1\n2\n333333333333333333333333\n4\n5\n6\n7\n8\n";
}
// クリックイベント
public function ButtonTest(e:MouseEvent):void {
var str:String = e.currentTarget.label+"";
str += "が押されれました";
if ( e.shiftKey ) {
str += " (Shift キーが押されています)";
}
else {
str += " (Shift キーは押されていません)";
}
// このメッセージが表示中に既に以下のデータ転送が
// 実行されている事に注目して下さい
Alert.show( str );
txt_01.text = txt_02.text;
}
// スクロールイベント
public function ScrollControl(e:mx.events.ScrollEvent):void {
// 右側のテキストエリア縦のスクロールバーが変化した場合に
// 左側のスクロールを同期させる
if ( e.direction == ScrollEventDirection.VERTICAL ) {
txt_01.verticalScrollPosition = e.position;
}
}
]]>
</mx:Script>
<mx:HBox>
<mx:TextArea
id="txt_01"
width="200"
height="100"
wordWrap="false"
horizontalScrollPolicy="on"
verticalScrollPolicy="off"
editable="false"
/>
<mx:TextArea
id="txt_02"
width="200"
height="100"
wordWrap="false"
horizontalScrollPolicy="on"
scroll="ScrollControl(event)"
/>
<mx:Button
id="btn_01"
label="ボタン"
click="ButtonTest(event)"
/>
</mx:HBox>
</mx:Application>
|