Files
qxzb/flash_decompiled/com/common/DragTools.as
2026-03-01 10:12:57 +08:00

101 lines
3.1 KiB
ActionScript

package com.common
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.geom.Rectangle;
public class DragTools
{
private var target:Sprite;
private var object:Object;
private var bm:Bitmap;
private var ra:Bitmap;
private var container:Sprite = new Sprite();
private var bd:BitmapData;
public function DragTools(param1:Sprite, param2:Object)
{
super();
this.target = param1;
this.object = param2;
}
public function beginDrag(param1:Boolean = false, param2:Rectangle = null) : void
{
var _loc3_:Rectangle = null;
if(this.object.methods == "bitmap")
{
if(this.bm != null)
{
return;
}
_loc3_ = this.target.getBounds(this.target.parent);
this.bd = new BitmapData(_loc3_.width,_loc3_.height);
this.bd.draw(this.target);
this.bm = new Bitmap(this.bd);
this.container.addChild(this.bm);
this.container.x = this.target.x;
this.container.y = this.target.y;
this.target.visible = false;
this.target.parent.addChildAt(this.container,this.target.parent.getChildIndex(this.target));
this.container.startDrag(param1,param2);
}
else if(this.object.methods == "rectangle")
{
this.container.graphics.lineStyle(4,10053171);
this.container.graphics.beginFill(0,0);
this.container.graphics.drawRect(0,0,this.target.width,this.target.height);
this.container.graphics.endFill();
this.container.x = this.target.x;
this.container.y = this.target.y;
this.target.parent.addChildAt(this.container,this.target.parent.getChildIndex(this.target) + 1);
this.container.startDrag(param1,param2);
}
else
{
this.target.startDrag(param1,param2);
}
}
public function endDrag() : void
{
if(this.object.methods == "bitmap")
{
if(this.bm == null)
{
return;
}
this.target.x = this.container.x;
this.target.y = this.container.y;
this.container.removeChild(this.bm);
this.target.parent.removeChild(this.container);
this.bm = null;
this.target.visible = true;
this.bd.dispose();
this.bd = null;
}
else if(this.object.methods == "rectangle")
{
this.target.x = this.container.x;
this.target.y = this.container.y;
this.container.graphics.clear();
this.container.x = 0;
this.container.y = 0;
this.target.parent.removeChild(this.container);
}
else
{
this.target.stopDrag();
}
}
}
}