Nikolajd
20.06.2009, 17:29
Помогте пожалуста исправить код resize на proportional resize. Вот код и сам флеш:
import flash.display.Shape;
import com.senocular.display.TransformTool;
// default tool
var defaultTool:TransformTool = new TransformTool();
addChild(defaultTool);
// custom tool with some custom options
var customTool:TransformTool = new TransformTool();
addChild(customTool);
customTool.raiseNewTargets = false;
customTool.moveNewTargets = true;
customTool.moveUnderObjects = false;
customTool.registrationEnabled = false;
customTool.rememberRegistration = false;
customTool.rotationEnabled = false;
customTool.constrainRotation = true;
customTool.constrainRotationAngle = 90/4;
customTool.constrainScale = true;
customTool.maxScaleX = 2;
customTool.maxScaleY = 2;
customTool.skewEnabled = false;
customTool.setSkin(TransformTool.SCALE_TOP_LEFT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_TOP_RIGHT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_BOTTOM_RIGHT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_BOTTOM_LEFT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_TOP, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_RIGHT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_BOTTOM, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_LEFT, new ScaleCircle());
customTool.addControl(new CustomRotationControl());
customTool.addControl(new CustomResetControl());
// keep track of the current tool being used
var currTool:TransformTool = defaultTool;
// selecting objects on the screen
function select(event){
if (event.target is Stage) {
currTool.target = null;
}else if (event.target is Sprite) {
currTool.target = event.target as Sprite;
toolInit();
}
}
// changing tools using the toolChange button
function setTool(event:MouseEvent):void {
// get other tool
var newTool:TransformTool = (currTool == defaultTool) ? customTool : defaultTool;
// make sure moveNewTargets is not set when setting tool this way
var moveTargets:Boolean = newTool.moveNewTargets;
newTool.moveNewTargets = false;
newTool.target = currTool.target;
newTool.moveNewTargets = moveTargets;
// unset currTool
currTool.target = null;
currTool = newTool;
toolInit();
}
// for setting a new tool
function toolInit():void {
// raise
currTool.parent.setChildIndex(currTool, currTool.parent.numChildren - 1);
// center registration for customTool
if (currTool == customTool) {
currTool.registration = currTool.boundsCenter;
}
}
// event handlers for selecting objects and changing tools
stage.addEventListener(MouseEvent.MOUSE_DOWN, select);
toolChange.addEventListener(MouseEvent.CLICK, setTool);
import flash.display.Shape;
import com.senocular.display.TransformTool;
// default tool
var defaultTool:TransformTool = new TransformTool();
addChild(defaultTool);
// custom tool with some custom options
var customTool:TransformTool = new TransformTool();
addChild(customTool);
customTool.raiseNewTargets = false;
customTool.moveNewTargets = true;
customTool.moveUnderObjects = false;
customTool.registrationEnabled = false;
customTool.rememberRegistration = false;
customTool.rotationEnabled = false;
customTool.constrainRotation = true;
customTool.constrainRotationAngle = 90/4;
customTool.constrainScale = true;
customTool.maxScaleX = 2;
customTool.maxScaleY = 2;
customTool.skewEnabled = false;
customTool.setSkin(TransformTool.SCALE_TOP_LEFT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_TOP_RIGHT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_BOTTOM_RIGHT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_BOTTOM_LEFT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_TOP, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_RIGHT, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_BOTTOM, new ScaleCircle());
customTool.setSkin(TransformTool.SCALE_LEFT, new ScaleCircle());
customTool.addControl(new CustomRotationControl());
customTool.addControl(new CustomResetControl());
// keep track of the current tool being used
var currTool:TransformTool = defaultTool;
// selecting objects on the screen
function select(event){
if (event.target is Stage) {
currTool.target = null;
}else if (event.target is Sprite) {
currTool.target = event.target as Sprite;
toolInit();
}
}
// changing tools using the toolChange button
function setTool(event:MouseEvent):void {
// get other tool
var newTool:TransformTool = (currTool == defaultTool) ? customTool : defaultTool;
// make sure moveNewTargets is not set when setting tool this way
var moveTargets:Boolean = newTool.moveNewTargets;
newTool.moveNewTargets = false;
newTool.target = currTool.target;
newTool.moveNewTargets = moveTargets;
// unset currTool
currTool.target = null;
currTool = newTool;
toolInit();
}
// for setting a new tool
function toolInit():void {
// raise
currTool.parent.setChildIndex(currTool, currTool.parent.numChildren - 1);
// center registration for customTool
if (currTool == customTool) {
currTool.registration = currTool.boundsCenter;
}
}
// event handlers for selecting objects and changing tools
stage.addEventListener(MouseEvent.MOUSE_DOWN, select);
toolChange.addEventListener(MouseEvent.CLICK, setTool);