// developed by jinni of moonfun studio // email: jinnilove@126.com var isValidDrag = false; function init() { } function configureTool() { theTool = fl.tools.activeTool; theTool.setToolName("Reset Stage"); theTool.setIcon("RS.png"); theTool.setMenuString("Reset Stage"); theTool.setToolTip("Reset Stage by jinni"); theTool.setOptionsFile( "RS.xml" ); init(); } function notifySettingsChanged() { theTool = fl.tools.activeTool; init(); } function activate() { theTool = fl.tools.activeTool; } function deactivate() { } function mouseDown() { var pointX = fl.tools.penLoc.x; var pointY = fl.tools.penLoc.y; var doc = fl.getDocumentDOM(); if(pointX>=(doc.width-20)&&pointX<=doc.width&&pointY>=(doc.height-20)&&pointY<=doc.height) { fl.drawingLayer.beginDraw(); isValidDrag=true; } } function mouseMove() { if(fl.tools.mouseIsDown && isValidDrag) { var w = fl.tools.penLoc.x; var h = fl.tools.penLoc.y; fl.drawingLayer.beginFrame(); fl.drawingLayer.moveTo(0,0); fl.drawingLayer.lineTo(w,0); fl.drawingLayer.lineTo(w,h); fl.drawingLayer.lineTo(0,h); fl.drawingLayer.lineTo(0,0); fl.drawingLayer.endFrame(); } } function mouseUp() { var doc = fl.getDocumentDOM(); var w,h; fl.drawingLayer.endDraw(); if(isValidDrag) { w = parseInt(fl.tools.penLoc.x); h = parseInt(fl.tools.penLoc.y); isValidDrag = false; doc.width = w; doc.height = h; } else isValidDrag = false; }