mardi 29 septembre 2015

Next button in drag and drop button doesnt function

I am trying to create a drag and drop game. I want to create a next button and it didnt work. If I remove the next button, the drag and drop game works fine but once I add the drag and drop button, then the whole game doesnt function. Here is my code. Can anyone help me?

import flash.events.MouseEvent;




var objectOriginalX:Number;
var objectOriginalY:Number;




answer.buttonMode = true;
answer.addEventListener(MouseEvent.MOUSE_DOWN, pickObject);
answer.addEventListener(MouseEvent.MOUSE_UP, dropObject);


answer1.buttonMode = true;
answer1.addEventListener(MouseEvent.MOUSE_DOWN, pickObject);
answer1.addEventListener(MouseEvent.MOUSE_UP, dropObject);




answer2.buttonMode = true;
answer2.addEventListener(MouseEvent.MOUSE_DOWN, pickObject);
answer2.addEventListener(MouseEvent.MOUSE_UP, dropObject);


answer3.buttonMode = true;
answer3.addEventListener(MouseEvent.MOUSE_DOWN, pickObject);
answer3.addEventListener(MouseEvent.MOUSE_UP, dropObject);

next_btn.buttonMode = true;
next_btn.addEventListener(MouseEvent.CLICK, next_btn);


/*next_btn.addEventListener(MouseEvent.CLICK,next_btn)
next_btn.buttonMode = true;*/

/*stop();
function next_btn(event:MouseEvent):void 
{
      gotoAndStop(5);
}*/


function pickObject(event:MouseEvent):void
{
  event.target.startDrag();
  event.target.parent.addChild(event.target);
  objectOriginalX = event.target.x;
  objectOriginalY = event.target.y;
}


function dropObject (event:MouseEvent):void
{
  event.target.stopDrag();
  var matchingTargetName:String = event.target.name + "Target" ;
  var matchingTarget: DisplayObject = getChildByName(matchingTargetName);

  if(event.target.dropTarget != null && event.target.dropTarget.parent == matchingTarget)
  {
  event.target.removeEventListener(MouseEvent.MOUSE_DOWN,pickObject);
  event.target.removeEventListener(MouseEvent.MOUSE_UP,dropObject);
  event.target.buttonMode = false;
  event.target.x = matchingTarget.x;
  event.target.y = matchingTarget.y;

  }

  else   { 
  event.target.x = objectOriginalX;
  event.target.y = objectOriginalY;
  }

  function next_btn.MovieClip(event:MouseEvent):void 
{
      gotoAndStop(5);
}

}


stop();

Aucun commentaire:

Enregistrer un commentaire