forked from: forked from: flash on 2014-11-26
forked from forked from: flash on 2014-11-26 (diff: 1607)
予定 ウィンドウ ドラッグ→OK リサイズ→まだ →ウィンドウ枠をドラッグ スクロールバー→まだ →targetのサイズに応じて タブ管理→まだ →タイトル
ActionScript3 source code
/**
* Copyright tepe ( http://wonderfl.net/user/tepe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/94YG
*/
// forked from tepe's forked from: flash on 2014-11-26
// forked from tepe's flash on 2014-11-26
// forked from tepe's 構文解析
//予定
/*
ウィンドウ
ドラッグ→OK
リサイズ→まだ
→ウィンドウ枠をドラッグ
スクロールバー→まだ
→targetのサイズに応じて
タブ管理→まだ
→タイトル
*/
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import net.hires.debug.Stats;
public class FlashTest extends Sprite {
public function FlashTest() {
var wp:WindowPanel = new WindowPanel();
addChild(wp);
wp.title = "test";
}
}//class
}//package
//=======================================================================================
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.ui.*;
class WindowPanel extends Sprite{
private var _title:String = "";
private var _mx:Number = 20;
private var _my:Number = 10;
private var _target:DisplayObject;
private var _tf:TextField;
public function WindowPanel(o:DisplayObject=null){
if(o!=null)target=o;
else{
var tf:TextField = new TextField();
tf.type = "input";
target = tf;
}
draw();
this.addEventListener(MouseEvent.MOUSE_MOVE,onMove);
this.addEventListener(MouseEvent.MOUSE_OUT,onOut);
this.addEventListener(MouseEvent.MOUSE_DOWN,onDrag);
this.addEventListener(MouseEvent.MOUSE_UP,onDrop);
}
public function set target(o:DisplayObject):void{
_target = o;
this.addChild(o);
this.x = o.x;
this.y = o.y;
o.x=0;
o.y=0;
draw();
}
public function set title(t:String):void{
_title = t;
initTF();
draw();
}
//タイトル表示
private function initTF():void{
_tf = null;
_tf = new TextField();
//_tf.border = true;
_tf.text = _title;
_tf.y = -_my;
_tf.selectable = false;
_tf.width = _tf.textWidth+5;
_tf.height = _tf.textHeight+5;
this.addChild(_tf);
}
//ウィンドウ更新
public function draw(c:uint=0xffffff,a:Number=0.8):void{
//initTF();
var w:Number,h:Number;
if(_target==null){w=this.width;h=this.height;}
else{
w=_target.width;h=_target.height;
this.x += _target.x;
this.y += _target.y;
_target.x = 0;
_target.y = 0;
}
this.graphics.clear();
this.graphics.lineStyle(0,0x0,a);
this.graphics.beginFill(c,a);
this.graphics.drawRect(-_mx,-_my,w+_mx*2,h+_my*2);
this.graphics.endFill();
}
//ロールアウト
private function onOut(e:MouseEvent):void{
Mouse.cursor = MouseCursor.AUTO;
}
//マウス移動
private function onMove(e:MouseEvent):void{
if(e.target == this)Mouse.cursor = MouseCursor.HAND;
else Mouse.cursor = MouseCursor.AUTO;
}
//ウィンドウドラッグ
private function onDrag(e:MouseEvent):void{
e.currentTarget.parent.setChildIndex(e.currentTarget, e.currentTarget.parent.numChildren-1); //並べ替え
if(e.target == this){
this.startDrag();
//var s:DisplayObject = stage.getChildByName(e.currentTarget.name);//ディスプレイオブジェクト取得
}
draw();
//this.startDrag();
}
private function onDrop(e:MouseEvent):void{
this.stopDrag();
draw();
}
}