IMPORT ALL IMAGES TO AS3 LIBRARY SECTION AND CHANGE INTO BUTTON &
MOVIE CLIPS
------------------------------------------------------------------------------------------------------------
PNG SEQUENCE FOR AS3 GAME
-------------------------------------------------------------------------------------------------------------
dog, bird, shark, birdTarget, sharkTarget, dogTarget, Reset_btn
-----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------
CREATE ACTION SCRIPT LAYER IN AS3 AND PASTE BELOW CODE
IN ACTION SCRIPT PANEL
-----------------------------------------------------------------------------
var ypos:int;
var xpos:int;
dragObjek(dog,bird,shark);
function getPos(target:Object) {
xpos=target.x;
ypos=target.y;
}
function startdrag(event:MouseEvent) {
event.target.startDrag(true);
getPos(event.target);
}
function stopdrag(event:MouseEvent) {
if (event.target.hitTestObject(getChildByName(event.target.name+"Target"))) {
event.target.x=getChildByName(event.target.name+"Target").x;
event.target.y=getChildByName(event.target.name+"Target").y;
} else {
event.target.x=xpos;
event.target.y=ypos;
}
event.target.stopDrag();
}
function dragObjek(... objects) {
for (var i:int = 0; i < objects.length; i++) {
objects[i].addEventListener(MouseEvent.MOUSE_DOWN, startdrag);
objects[i].addEventListener(MouseEvent.MOUSE_UP, stopdrag);
}}
Reset_btn.addEventListener(MouseEvent.CLICK, choose);
function choose(event:MouseEvent):void{
dog.x = 89;
dog.y = 66.35;
bird.x = 96.50;
bird.y = 176.50;
shark.x = 94.50;
shark.y = 271.70;
}
-------------------------------------------------------------------------------
OR USE THIS CODE WITH RESET BUTTON
http://flashcollege.blogspot.co.uk/2014/09/hit-test-in-as3-and-score-count.html
CREATE TWO MOVIE CLIPS AND GIVE INSTANCE NAME
square_mc , targetsquare_mc
CREATE ONE BUTTON AND GIVE INSTANCE NAME
Reset_btn
--------------------------------------------------------------------------------
var counter:Number = 0;
var startX:Number = square_mc.x
var startY:Number = square_mc.y
square_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
function pickUp(event:MouseEvent):void {
event.target.startDrag(true);
reply_txt.text = "";
event.target.parent.addChild(event.target);
startX = event.target.x;
startY = event.target.y;
}
square_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function dropIt(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTarget:DisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
reply_txt.text = "Good Job!";
event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
}
else {
reply_txt.text = "Try Again";
event.target.x = startX;
event.target.y = startY;
}
if(counter == 1){
reply_txt.text = "You'Are Done";
}
}
square_mc.buttonMode = true;
Reset_btn.addEventListener(MouseEvent.CLICK, choose);
function choose(event:MouseEvent):void{
reply_txt.text = "Start Again";
square_mc.x = startX
square_mc.y = startY
square_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
square_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
}
--------------------------------------------------------------------------------
READMORE:
http://flash.6f.sk/flash_forum/AS3/drag_and_drop/drag_and_drop_as3.html
https://www.youtube.com/watch?v=E-IXI3GJWvk
http://www.flashandmath.com/basic/dragdroptour/dd_tour5.html
http://board.flashkit.com/board/showthread.php?826316-Multiple-drag-and-drops
https://www.dropbox.com/s/sbt810go40oimlb/draganddroptotargetEGyoutube.fla
http://www.swinburne.edu.au/design/tutorials/P-flash/T-How-to-drag-and-drop-in-Flash/ID-37/
---------------------------------------------------------------------------------------------------------
Well say you have 5 movie clips on the stage all named hat, shoes, pants... respectivley.
Now in your actionscript you can set variables to each MC as to their start position
hat.startX = hat._x;
hat.startY = hat._y;
etc...
when you click reset button it would look like
reset.onRelease = function() {
hat._x = hat.startX;
hat._y = hat.startY;
pants._x = pants.startX;
.....
}
-----------------------------------------------------------------------------------------------------------
https://www.youtube.com/watch?v=SZnnNSgfz8Y
http://www.ilike2flash.com/2008/06/drop-target-property.html
http://www.danfergusdesign.com/classfiles/oldClasses/VCB424-AdvInterDes4/exercises/ex-matchingNew.html
http://www.danfergusdesign.com/classfiles/oldClasses/VCB324-richMedia2/exercises/matchingGame.php
http://board.flashkit.com/board/showthread.php?606420-reset-position-of-drag-and-drop-gamehttps://www.youtube.com/watch?v=E-IXI3GJWvk
http://www.flashandmath.com/basic/dragdroptour/dd_tour5.html
http://board.flashkit.com/board/showthread.php?826316-Multiple-drag-and-drops
https://www.dropbox.com/s/sbt810go40oimlb/draganddroptotargetEGyoutube.fla
http://www.swinburne.edu.au/design/tutorials/P-flash/T-How-to-drag-and-drop-in-Flash/ID-37/
---------------------------------------------------------------------------------------------------------
Well say you have 5 movie clips on the stage all named hat, shoes, pants... respectivley.
Now in your actionscript you can set variables to each MC as to their start position
hat.startX = hat._x;
hat.startY = hat._y;
etc...
when you click reset button it would look like
reset.onRelease = function() {
hat._x = hat.startX;
hat._y = hat.startY;
pants._x = pants.startX;
.....
}
-----------------------------------------------------------------------------------------------------------
var startPosition:Point;
mc_d4.addEventListener(MouseEvent.MOUSE_DOWN, dragD4);
stage.addEventListener(MouseEvent.MOUSE_UP, dragStop4);
function dragD4(e:Event):void {
mc_d4.startDrag();
startPosition = new Point( mc_d4.x, mc_d4.y);
}
function dragStop4(e:Event):void {
mc_d4.stopDrag();
//set back or tween position
mc_d4.x = startPosition.x;
mc_d4.y = startPosition.y;
startPosition = null;
}
https://www.youtube.com/watch?v=SZnnNSgfz8Y
http://www.ilike2flash.com/2008/06/drop-target-property.html
txt_mc._visible = false; banana_mc.onPress = function() { this.startDrag(); txt_mc._visible = false; }; banana_mc.onRelease = function() { this.stopDrag(); if (eval(this._droptarget) == monkey_mc) { txt_mc._visible = true; } };
-----------------------------------------------------------------------------
DRAG DROP WITH RESET BUTTON IN AS3Download Sourcehttp://www24.zippyshare.com/v/tZPxZyVI/file.htmlCREATE 11 MOVIE CLIPS AND GIVE INSTANCE NAMEcarrot,apple,pepper,banana,strawberry
carrotTarget,appleTarget,pepperTarget,bananaTarget,strawberryTargetReset_btnCREATE ACTION SCRIPT LAYER IN AS3 AND PASTE BELOW CODEIN ACTION SCRIPT PANEL
MY SPRITES & SPRITE SHEET-----------------------------------------------------------------------------var xPos:int; var yPos:int; var appleX:Number=apple.x; var appleY:Number=apple.y; var carrotX:Number=carrot.x; var carrotY:Number=carrot.y; var strawberryX:Number=strawberry.x; var strawberryY:Number=strawberry.y; var bananaX:Number=banana.x; var bananaY:Number=banana.y; var pepperX:Number=pepper.x; var pepperY:Number=pepper.y; function Main():void { addListeners(apple, carrot, strawberry, banana, pepper); } function getPosition(target:Object):void { xPos=target.x; yPos=target.y; } function dragObject(e:MouseEvent):void { getPosition(e.target); e.target.startDrag(true); } function stopDragObject(e:MouseEvent):void { if (e.target.hitTestObject(getChildByName(e.target.name+"Target"))) { e.target.x=getChildByName(e.target.name+"Target").x; e.target.y=getChildByName(e.target.name+"Target").y; } else { e.target.x=xPos; e.target.y=yPos; } e.target.stopDrag(); } function addListeners(... objects):void { for (var i:int = 0; i < objects.length; i++) { objects[i].addEventListener(MouseEvent.MOUSE_DOWN, dragObject); objects[i].addEventListener(MouseEvent.MOUSE_UP, stopDragObject); }} Main(); Reset_btn.addEventListener(MouseEvent.CLICK, choose); function choose(event:MouseEvent):void{ apple.x=appleX; apple.y=appleY; carrot.x=carrotX; carrot.y=carrotY; strawberry.x=strawberryX; strawberry.y=strawberryY; banana.x=bananaX; banana.y=bananaY; pepper.x=pepperX; pepper.y=pepperY; } =======================================================================================
CROWN DRAG DROP STOP WITH RESET IN AS3
http://www.virtualmv.com/wiki/index.php?title=ActionScript3%3ADrag_and_Drop_with_Targets
https://www.youtube.com/watch?v=i1BXtCvVIOQ
DOWNLOAD SOURCE:
http://bit.ly/1B3oPKT
=======================================================================================
COPY AND PASTE BELOW CODE
CREATE TWO MOVIE CLIPS ONE RESET BUTTON AND TEXT
crownMc , targetcrownMc , Reset , handsome_txt=======================================================================================//http://www.virtualmv.com/wiki/index.php?title=ActionScript3%3ADrag_and_Drop_with_Targets crownMc.buttonMode = true; var startX:Number; var startY:Number; var dropCount:Number = 0; dropCount++; crownMc.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown) function MouseDown(event:MouseEvent):void { event.target.startDrag(true); startX = event.target.x; startY = event.target.y; } crownMc.addEventListener(MouseEvent.MOUSE_UP, MouseUp); function MouseUp(event:MouseEvent):void { event.target.stopDrag(); var myTargetName:String = "target" + event.target.name; var myTarget:DisplayObject = getChildByName(myTargetName) if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){ event.target.removeEventListener(MouseEvent.MOUSE_DOWN,MouseDown) event.target.removeEventListener(MouseEvent.MOUSE_UP,MouseUp) event.target.buttonMode = false; event.target.x = myTarget.x; event.target.y = myTarget.y; handsome_txt.text = "Good Job!" } else { event.target.x = startX; event.target.y = startY; if(dropCount == 1){ handsome_txt.text = "No Handsome Prince under this Crown!"; }}} Reset.addEventListener(MouseEvent.CLICK,MouseClick); function MouseClick(event:MouseEvent):void{ crownMc.addEventListener(MouseEvent.MOUSE_DOWN,MouseDown) crownMc.addEventListener(MouseEvent.MOUSE_UP,MouseUp); crownMc.x = startX; crownMc.y = startY; handsome_txt.text = "Play Again!" }-------------------------------------------------------------------------------------------------------------SIMPLE DRAG ME AS3 RESET BUTTON//First Make DragMeTarget MovieClip//Second Make DragMe MovieClip//Third Draw reply_txt Box//Four Make Reset Button And Paste Below Codehttps://www.youtube.com/watch?v=EgZCUgI39J4
Download Source:--------------------------------------------------------------------------------------------------------------COPY AND PASTE BELOW CODE---------------------------------------------------------------------------------------------------------------//First Make DragMeTarget MovieClip//Second Make DragMe MovieClip//Third Draw reply_txt Box//Four Make Reset Button And Paste Below Codevar startX:Number;var startY:Number;DragMe.addEventListener(MouseEvent.MOUSE_DOWN,MouseDown)function MouseDown(e:MouseEvent):void {startX = e.target.x;startY = e.target.y;e.target.startDrag(true);}DragMe.addEventListener(MouseEvent.MOUSE_UP,MouseUp)function MouseUp(e:MouseEvent):void {e.target.stopDrag();if (e.target.hitTestObject(getChildByName(e.target.name+"Target"))) {e.target.x=getChildByName(e.target.name+"Target").x;e.target.y=getChildByName(e.target.name+"Target").y;e.target.removeEventListener(MouseEvent.MOUSE_DOWN,MouseDown)e.target.removeEventListener(MouseEvent.MOUSE_UP,MouseUp)reply_txt.text = "Good Job!"}else {e.target.x=startX;e.target.y=startY;reply_txt.text = "Try Again!"}}Reset.addEventListener(MouseEvent.CLICK,MouseClick);function MouseClick(event:MouseEvent):void{DragMe.addEventListener(MouseEvent.MOUSE_DOWN,MouseDown)DragMe.addEventListener(MouseEvent.MOUSE_UP,MouseUp);DragMe.x = startX;DragMe.y = startY;reply_txt.text = "Play Again!"}
1 comments:
Drag Drop With Reset Button In As2 As3 - Flash College >>>>> Download Now
>>>>> Download Full
Drag Drop With Reset Button In As2 As3 - Flash College >>>>> Download LINK
>>>>> Download Now
Drag Drop With Reset Button In As2 As3 - Flash College >>>>> Download Full
>>>>> Download LINK UQ
EmoticonEmoticon