Highlighted

GoTo next frame after droping all the right pieces

Community Beginner ,
Feb 05, 2019

Copy link to clipboard

Copied

Kindly need a help

i had this script of drag and drop game

but i have one one problem to go to the next frame after i drop all the objects to target

anyone have solution?

import flash.events.MouseEvent;

import flash.display.DisplayObject;

var objectoriginalX:Number;

var objectoriginalY:Number;

blue.buttonMode = true;

blue.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);

blue.addEventListener(MouseEvent.MOUSE_UP, dropObject);  

red.buttonMode = true;

red.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);

red.addEventListener(MouseEvent.MOUSE_UP, dropObject);

green.buttonMode = true;

green.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);

green.addEventListener(MouseEvent.MOUSE_UP, dropObject);

function pickupObject(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 = "target" + event.target.name;

var matchingTarget:DisplayObject = getChildByName(matchingTargetName);

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

{

event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickupObject);

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;

}

}

TOPICS
ActionScript

Views

149

Likes

Translate

Translate

Report

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

GoTo next frame after droping all the right pieces

Community Beginner ,
Feb 05, 2019

Copy link to clipboard

Copied

Kindly need a help

i had this script of drag and drop game

but i have one one problem to go to the next frame after i drop all the objects to target

anyone have solution?

import flash.events.MouseEvent;

import flash.display.DisplayObject;

var objectoriginalX:Number;

var objectoriginalY:Number;

blue.buttonMode = true;

blue.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);

blue.addEventListener(MouseEvent.MOUSE_UP, dropObject);  

red.buttonMode = true;

red.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);

red.addEventListener(MouseEvent.MOUSE_UP, dropObject);

green.buttonMode = true;

green.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);

green.addEventListener(MouseEvent.MOUSE_UP, dropObject);

function pickupObject(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 = "target" + event.target.name;

var matchingTarget:DisplayObject = getChildByName(matchingTargetName);

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

{

event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickupObject);

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;

}

}

TOPICS
ActionScript

Views

150

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 05, 2019 0
kglad LATEST
Adobe Community Professional ,
Feb 06, 2019

Copy link to clipboard

Copied

  • import flash.events.MouseEvent; 
  • import flash.display.DisplayObject; 
  •  
  •  
  • var objectoriginalX:Number; 
  • var objectoriginalY:Number; 

var objNum:int = 3;

var correctNum:int = 0;

  •  
  • blue.buttonMode = true
  • blue.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject); 
  • blue.addEventListener(MouseEvent.MOUSE_UP, dropObject);    
  •  
  •  
  • red.buttonMode = true
  • red.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject); 
  • red.addEventListener(MouseEvent.MOUSE_UP, dropObject); 
  •  
  •  
  • green.buttonMode = true
  • green.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject); 
  • green.addEventListener(MouseEvent.MOUSE_UP, dropObject); 
  •  
  •  
  • function pickupObject(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 = "target" + event.target.name; 
  • var matchingTarget:DisplayObject = getChildByName(matchingTargetName); 
  • if(event.target.dropTarget != null && event.target.dropTarget.parent == matchingTarget) 
  • event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickupObject); 
  • event.target.removeEventListener(MouseEvent.MOUSE_UP, dropObject); 
  • event.target.buttonMode = false
  • event.target.x = matchingTarget.x; 
  • event.target.y = matchingTarget.y;

correctNum++;

if(correctNum==objNum){

nextFrame()

}

  • else 
  • event.target.x = objectoriginalX; 
  • event.target.y = objectoriginalY; 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2019 0