fishb0n3
August 25th, 2008, 07:40 AM
i found a tutorial in this site where it teaches me the drag and drop function. however, what i want is to drag a movie clip to a stage, and when it is released on the stage, the movie clip will return to its original position.
What actionscript should i use? Can someone please help me? Can it be done by using the iconReleased script? how?
Anil_kumar
August 27th, 2008, 06:59 AM
just paste this code (AS3) in ur Flash CS3 document you don't need to create anything on the stage
or
download the attached file
click here (http://flash-workshop.blogspot.com/2008/08/flash-cs3-drag-and-drop-simple-game.html) to C an example
.................................................. ......................
import fl.transitions.Tween;
import fl.transitions.easing.*;
stage.frameRate=30;
var TargetCircle = CreateCircle(0x00FF00,100);
TargetCircle.x=350;
TargetCircle.y=200;
addChild(TargetCircle);
var SmallCircle = CreateCircle(0xFF6600,10);
SmallCircle.x=50;
SmallCircle.y=200;
SmallCircle.buttonMode = true;
SmallCircle.addEventListener(MouseEvent.MOUSE_DOWN ,DOWNHandler);
SmallCircle.addEventListener(MouseEvent.MOUSE_UP,U PHandler);
addChild(SmallCircle);
function DOWNHandler(e:MouseEvent) {
e.target.startDrag();
}
function UPHandler(e:MouseEvent) {
e.target.stopDrag();
if (SmallCircle.hitTestObject(TargetCircle)==false) {
TweenHandler();
}
}
function CreateCircle(color:Number,radius:Number):MovieClip {
var circle:MovieClip = new MovieClip;
circle.graphics.beginFill(color,1);
circle.graphics.drawCircle(0,0,radius);
circle.graphics.endFill();
return circle;
}
function TweenHandler() {
var tweenX = new Tween(SmallCircle,"x",Regular.easeInOut,SmallCircle.x,50,1,true);
var tweenY = new Tween(SmallCircle,"y",Regular.easeInOut,SmallCircle.y,200,1,true);
}
.................................................. ......................
Anil
anilkumarnd@gmail.com
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.