Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem with drag and drop

New Here ,
May 06, 2013 May 06, 2013

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");

    }

}

TOPICS
ActionScript
521
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2013 May 06, 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");

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2013 May 06, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2013 May 06, 2013
LATEST

you have some mismatched brackets, change your target properties to currentTarget (and i'm not sure you're dropping onto the correct target) but, 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");

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines