 | 1: package { 2: import flash.text.*; 3: import flash.display.*; 4: import flash.events.*; 5: import flash.system.*; 6: import mx.controls.*; 7: 8: public class Sticky { 9: public var window:NativeWindow; // 付箋ウィンドウ 10: public var editor:TextField; // 入力欄 11: public var id:Number; // 主キー 12: public static var RESIZE_HANDLE_SIZE:int = 20; // リサイズ用領域の大きさ 13: 14: // 付箋ウィンドウを生成 15: public function Sticky():void { 16: var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions(); 17: initOptions.systemChrome = NativeWindowSystemChrome.NONE; 18: initOptions.transparent = false; 19: initOptions.type = NativeWindowType.LIGHTWEIGHT; 20: window = new NativeWindow(false, initOptions); 21: window.stage.align = StageAlign.TOP_LEFT; 22: window.stage.scaleMode = StageScaleMode.NO_SCALE; 23: 24: // 入力欄 25: editor = new TextField(); 26: editor.x = editor.y = 0; 27: editor.selectable = true; 28: editor.border = false; 29: editor.type = TextFieldType.INPUT; 30: editor.multiline = true; 31: editor.background = true; 32: editor.wordWrap = true; 33: editor.backgroundColor = 0xE6E082; 34: window.stage.addChild(editor); 35: 36: // ウィンドウと入力欄のサイズ 37: window.width = editor.width = 300; 38: window.height = editor.height = 100; 39: 40: // ウィンドウをリサイズすると入力欄も追従 41: window.stage.addEventListener(Event.RESIZE, function(evt:Event):void { 42: resized(); 43: }); 44: 45: // 移動とリサイズ 46: window.stage.addEventListener(MouseEvent.MOUSE_DOWN, 47: function(evt:MouseEvent):void { 48: var x:Number = evt.stageX; 49: var y:Number = evt.stageY; 50: if (y > window.height - RESIZE_HANDLE_SIZE && x > window.width - RESIZE_HANDLE_SIZE) { 51: window.startResize(NativeWindowResize.BOTTOM_RIGHT); 52: } 53: else { 54: window.startMove(); 55: } 56: } 57: ); 58: } // end of function Sticky 59: 60: // ウィンドウを表示する 61: public function show():void { 62: window.visible = true; 63: } 64: 65: // ウィンドウをリサイズしたあとに呼ばれる 66: public function resized():void { 67: editor.width = window.width; 68: editor.height = window.height; 69: } 70: 71: } // end of class Sticky 72: 73: } // end of package
|  |