How to make a click and drag formulary in Flash

7 posts

Flag Post

Hi everyone!

I’m trying to make a box that contains a formulary. I’ve already built this box with it’s texts, text boxes, buttons, images…

Now, I discovery that it’s possible to drag this box using Action.
The code is something like this:

on(Press) = function(){
on(Release) = function(){

I’ve done and it worked well!

But my problem is that doing it, I became unable to write things on the formulary and press the buttons.

So, I want to know if there’s any way to do a box with a formulary in it that can be dragged (that doesn’t jeopardize my form…)

I dislike to make Actions, so if there’s any way to do it in ActionScrips (classes), I would be glad!

Flag Post
var dx:int;
var dy:int
var dragging:Boolean;
function _onMouseDown(event:MouseEvent){
    dx = object.x - mouseX;
    dy = object.y - mouseY;
    dragging = true;
function _onMouseUp(event:MouseEvent){
    dragging = false;
function _onEnterFrame(event:Event){
        object.x = mouseX + dx;
        object.y = mouseY + dy;

I’m pretty sure that this is not the right argument for startDrag()

startDrag(lockCenter:Boolean = false, bounds:Rectangle = null):void
It should be, this.startDrag(); this.stopDrag();

Flag Post

I love this way you did it, feartehstickman, tks!

But do you know how to make it in Action Script 2?
And how to import the MouseEvent in the Action Script 2?

Because I’ve started my project in AS2, not in AS3…


Flag Post

fearthestickman: It’d be better to use a mouseMove listener instead of the boolean/frame thing.

Flag Post

I found the sollution:
(I’ll replace the _ symbol to the \ becaus kongregate changes it to italic)

class Form extends Movieclip{
   function onLoad(){
      \root.form.onMouseDown = function(){
         var f\wh\2 = \width / 2;
         var f\ht\2 = \height / 2;
         if((\xmouse > 0 – f\wh\2 && \xmouse < f\wh\2)&&(\ymouse > 0 -f\ht\2 && \ymouse < f\ht\2)){
      \root.fundo.onMouseUp = function(){

Flag Post

Here is the game I was doing:

The option menu is dragable…

Flag Post
Originally posted by Senekis93:

fearthestickman: It’d be better to use a mouseMove listener instead of the boolean/frame thing.

Ah ok. I didn’t know that was a thing, but it would make everything easier. Thankyou.