Skip to main content
Participant
May 6, 2013
Question

Problem with drag and drop

  • May 6, 2013
  • 1 reply
  • 549 views

Hi! I'm having a problem with getting this code working, basically I want to drag and drop two things onto another the things dissapear then it moves onto a new page, the first item works properly but then the second item wont dissapear and remains stuck to the cursor. Heres the code I'd be greatful of any help.

import flash.events.MouseEvent;

import fl.motion.MotionEvent;

stop();

Back6_btn.addEventListener(MouseEvent.CLICK, onBack6Click)

function onBack6Click(event:MouseEvent):void{

    gotoAndPlay("Bedroom2");

}

    Forward6_btn.addEventListener(MouseEvent.CLICK, onForward6Click)

function onForward6Click(event:MouseEvent):void{

    gotoAndPlay('Brother bit');

}

var inGran:Number=0;

Gin.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);

Tonic.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);

function dragOn(event:MouseEvent):void {

    event.target.startDrag(false);

}

{

    stage.addEventListener(MouseEvent.MOUSE_UP, dragOff);

    }

function dragOff(event:MouseEvent):void {

    event.target.stopDrag();

    if (event.target.dropTarget!=null&&event.target.dropTarget.parent==Gran) {

        event.target.visible=false;

        inGran++;

    }

    stage.removeEventListener(MouseEvent.MOUSE_UP, dragOff);

}

function checkPage(e:Event):void {

    if (inGran==2) {

        gotoAndPlay("Bedroom1");

    }

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 6, 2013

try:

import flash.events.MouseEvent;

import fl.motion.MotionEvent;

stop();

Back6_btn.addEventListener(MouseEvent.CLICK, onBack6Click)

function onBack6Click(event:MouseEvent):void{

    gotoAndPlay("Bedroom2");

}

    Forward6_btn.addEventListener(MouseEvent.CLICK, onForward6Click)

function onForward6Click(event:MouseEvent):void{

    gotoAndPlay('Brother bit');

}

var inGran:Number=0;

Gin.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);

Tonic.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);

function dragOn(event:MouseEvent):void {

event.currentTarget.parent.addChild(event.currentTarget);

    event.target.startDrag(false);

}

{

    stage.addEventListener(MouseEvent.MOUSE_UP, dragOff);

    }

function dragOff(event:MouseEvent):void {

    event.target.stopDrag();

    if (event.target.dropTarget!=null&&event.target.dropTarget.parent==Gran) {

        event.target.visible=false;

        inGran++;

    }

    stage.removeEventListener(MouseEvent.MOUSE_UP, dragOff);

}

function checkPage(e:Event):void {

    if (inGran==2) {

        gotoAndPlay("Bedroom1");

    }

}

Participant
May 6, 2013

Hi, thanks again for the quick reply but this code is just doing the same as the original