Drag & Drop - Snap To Original Position
Hi, I'm trying to do drag & drop. I have the drag working. I'm getting the feedback from trace letting me know when my movie clips hit the targets & which ones. I cannot get my movie clips to snap back to the original position if they do not hit a target. That is what I'm trying to find out.
I have a movie clip (clip1) and a button within the movie clip. My target areas are numbered 1 to 4 (target1). The following code is on the button.
on (press) { this.startDrag (false); }
on (release) { this.stopDrag();
if (_root.clip1._droptarget == "/target1") { trace ("clip 1 in target 1"); } if (_root.clip1._droptarget == "/target2") { trace ("clip 1 in target 2"); } if (_root.clip1._droptarget == "/target3") { trace ("clip 1 in target 3"); } if (_root.clip1._droptarget == "/target4") { trace ("clip 1 in target 4"); } else { this_y= OrgY; this_x= OrgX; } }
Please help
ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)
Posted on: 05-22-2004, 08:57 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Making A 'drag N Drop' Object Snap To A Position
Howdy all, just a quick question. In following on from the 'drag and drop' tutorial, how would I make the object that i'm dragging snap to a particular position (lets say a tshirt snapping to a body)? Thanks all, BP
Drag N Drop (reset Draggable Objects To Original Position)
Hi! I have attached a screengrab of a Drag n Drop game I am working on. Currently, here is how it works:
I am defining a function on the first frame. I also call that function on the first frame to enable the drag n drop of the 6 chores on the left into the slots on the right. After dragging, the user clicks the "go to Next Day" button. The main timeline advances to the next frame where it re-defines the function and calls it again (to set different variables - I know this may not be the best way but I am crunched for time). Here is my problem:
When the "go to Next Day" button is clicked I need the draggable items to reset back to their original positions before the function is called. Currently they are staying in the slots on the right.
Here is the function and the call on the first frame:
Code:
function DragSetup(Obj, Target) {
Obj.Target = Target;
Obj.onPress = function() {
this.x = this._x;
this.y = this._y;
this.startDrag();
}
Obj.onRelease = function() {
this.stopDrag();
Drop = eval(this._droptarget);
if (this == chore1) {
_global.w1d1 = _global.w1d1 + 14;
} else if (this == chore2) {
_global.w1d1 = _global.w1d1 + 16;
} else if (this == chore3) {
_global.w1d1 = _global.w1d1 + 7;
} else if (this == chore4) {
_global.w1d1 = _global.w1d1 + 7;
} else if (this == chore5) {
_global.w1d1 = _global.w1d1 + 14;
} else if (this == chore6) {
_global.w1d1 = _global.w1d1 + 7;
}
daypoints.text = _global.w1d1;
for (a in Target) {
if (Drop == Target[a]) {
this._x = Target[a]._x;
this._y = Target[a]._y;
Check = 1;
return;
}
if (!Check) {
this._x = this.x;
this._y = this.y;
}
Check = 0;
}
}
}
DragSetup(chore1, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore2, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore3, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore4, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore5, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore6, [target1, target2, target3, target4, target5, target6]);
Here is the function and call on the second frame:
Code:
function DragSetup(Obj, Target) {
Obj.Target = Target;
Obj.onPress = function() {
this.x = this._x;
this.y = this._y;
this.startDrag();
}
Obj.onRelease = function() {
this.stopDrag();
Drop = eval(this._droptarget);
if (this == chore1) {
_global.w1d2 = _global.w1d2 + 14;
} else if (this == chore2) {
_global.w1d2 = _global.w1d2 + 16;
} else if (this == chore3) {
_global.w1d2 = _global.w1d2 + 7;
} else if (this == chore4) {
_global.w1d2 = _global.w1d2 + 7;
} else if (this == chore5) {
_global.w1d2 = _global.w1d2 + 14;
} else if (this == chore6) {
_global.w1d2 = _global.w1d2 + 7;
}
daypoints.text = _global.w1d2;
for (a in Target) {
if (Drop == Target[a]) {
this._x = Target[a]._x;
this._y = Target[a]._y;
Check = 1;
return;
}
if (!Check) {
this._x = this.x;
this._y = this.y;
}
Check = 0;
}
}
}
DragSetup(chore1, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore2, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore3, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore4, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore5, [target1, target2, target3, target4, target5, target6]);
DragSetup(chore6, [target1, target2, target3, target4, target5, target6]);
Could someone please show me how to reset these objects to their original positions when it advances to the second frame? A
lso, can someone tell me how to lock the draggable objects once they are dropped? Currently, you can keep moving them after dropping and it is messing up the "points" accumulation system.
Thanks,
aswhitehead
Drag&drop-move Item Back To Original Position
I am making a flash site to view photos. I have created thumbnails which can be dragged to a viewing box where the photo is enlarged and snapped into place for viewing. The thumbnails are movie clips with buttons placed inside of them. The buttons have this code on them:
on (press) {
startDrag ("_root.betsy");
}
on (release) {
turnOff();
stopDrag ();
if (_root.betsy._droptarget == "/box") {
_root.box.gotoandStop("betsy");
}
}
"Betsy" is the name of one particular thumbnail. "Box" is the target viewing area. I would like the thumbnail to snap back to its original position after being dragged onto the viewing box. I want to keep the large photo open in the viewing box after the thumbnail has snapped back into place. What do I need to do?
-Abbie
Snap To Original Position
Hi,
I'm trying to do drag & drop. I have the drag working. I'm getting the feedback from trace letting me know when my movie clips hit the targets & which ones.
I cannot get my movie clips to snap back to the original position if they do not hit a target. That is what I'm trying to find out.
I have a movie clip (clip1) and a button within the movie clip. My target areas are numbered 1 to 4 (target1). The following code is on the button.
on (press) {
this.startDrag (false);
}
on (release) {
this.stopDrag();
if (_root.clip1._droptarget == "/target1") {
trace ("clip 1 in target 1");
}
if (_root.clip1._droptarget == "/target2") {
trace ("clip 1 in target 2");
}
if (_root.clip1._droptarget == "/target3") {
trace ("clip 1 in target 3");
}
if (_root.clip1._droptarget == "/target4") {
trace ("clip 1 in target 4");
}
else {
this_y= OrgY;
this_x= OrgX;
}
}
Please help :)
Return Drag Mc To Original Position
I don't know how to do this! It makes my head ache. Please help me!!! How can I make my dragged movie clip back to its original position after clicking a reset button?
Thank you so much to anyone who can help...
DRAG 'N DROP 'N SNAP
someone please tell me the script for the drag and drop action used in jigsaw puzzle...where it snaps to the location..I have 8 mcs which are draggable butons...I dont want that for e.g. "MC1" should snap to "MC1target" when dropped but should be snapping when dropped over a predefined area
ANY HELP WELCOMED
Drag-Drop-Snap
does anyone know where i can find some really good drag and drop code where the object will snap into place when dropped in the right area.
does this make sense?
thanks.
Drag / / Drop / / Snap---->action BUT HOW?
I have got an action-script problem: Idrag and drop an object into a certain position (name="drop"). then I want an action like LoadMovie, TellTarget or StartSound to accur.
This is the code of my object (button inside movie clip):
on (press) {
this.startDrag();
}
on (release, releaseOutside) {
this.stopDrag();
// 50 pixels around the center of "drop" is the hit area
if (_x>_root.drop._x-50 && _x<_root.drop._x+50 && _y>_root.drop._y-50 && _y<_root.drop._y+50) {
_x = _root.drop._x;
_y = _root.drop._y;
}
}
PLEASE HELP ME!!
Drag And Drop Snap To Target
Hi
Could someone please help me with the code required to make a drag object snap onto a target(s) when in close proximity?
Many thanks
Drag And Drop Snap Effect
i got it to snap into place but how would i make it so once its in the right spot, it locks into place so you cant move it anymore?
here is my current code:
Code:
onClipEvent(enterFrame){
if(this._x > (549.5)-5 and this._x < (549.5)+5 and this._y > (70.5)-5 and this._y < (70.5)+5){
this._x = 549.5;
this._y = 70.5;
}
}
Drag And Drop Snap To Grid
Yo everyone.
This is my first time on here, so go easy.
I am working an interactive interface which uses drag and drop to drop certain bits into a defined area. You basically have a series of boxes which you drag out, and when you release, they expand through an animation. Then when you drag them back to their starting area, they return back to their original shape.
So far I have just been disecting how other people do their coding and just tried to apply the way they have done it to how I want mine to be, without having to rip off their coding.
Ideally what I want to do now is to create a grid with a series of invisble points which the boxes will snap to when you drag them out. So, similarly when you drag them back to their starting point area, they will snap in and return back to their original shape.
I have been looking at how people have created grids to allow snapping for drag and drop operations but to be honest it is just perplexing really with the coding, none have explained why they are doing this. At least, I am finding it hard to apply their technique into my scene. So, I was wondering if anyone can give me any insights into the reasoning/meaning behind the coding to create a snap grid. I.e., which bit defines the snapping area, how big each snap point would be...things like that. Would be really great.
If need be I can upload the swf of what I have so far.
Cheers
[FMX] HELP PLEASE Looping Drag N Drop, Snap To..
I've been assigned the task of creating a virtual sign maker. Theres 3 basic concepts, there are letters and other characters, a grid, and a trash can. The letters are draggable and i can get that to work, but i cant make the letters snap to the grid. Also i want to loop the letters so when i drag one another appears, and if not i can drag back a letter into place and it'll snap. The other problem im having is finding a way to delete letters not wanted on the grid. I need help asap because im braindead in the world of actionscript and i've beeen trying for days looking at tutorials. If you can help me out with some coding that would be greatly appreciated.
I've attached a FLA.
Drag, Drop And Snap Question
Hello-
I am currently working on a game which includes a drag and drop timeline; however, I am unable to get the items to snap into their correct position. I can get the items to snap when dropped, they just do not snap into the center or in a proper alignment. They basically snap anywhere near the target and it looks really sloppy.
Does anyone know the code to make them snap to the center of the movie clip they are dropped to? Here is the code I am currently using:
on (press) {
startDrag ("_root.draft");
}
on (release) {
stopDrag ();
if (this.hitTest(_root.three)) {
//snaps to timeline
_root.draft._x = _root.three._x;
_root.draft._y = _root.three._y;
}
}
Any help would be greatly appreciated!
Thanks,
-Crystal :-)
[AS] Drag And Drop; Return To Original Pos.
Hi, if anyone can help with this as its driving me nuts! Trying to build a drag and drop navigation, all the drag and drop works great, the test for the hit works ie if its on the target it centers the drag clip over the target, if its of the target the drag clip returns to its start postion. What I cannot get right is the code to check if the target already has a clip on it, if it has that clip needs to return to its start position, so we only ever have one drag clip on the target.
code timeline:
//
// initialize vars
left = 10;
right = 500;
top = 10;
bottom = 380;
speed = 10;
targetX = targetSpot_mc._x;
targetY = targetSpot_mc._y;
//
// test movieclip position
function targetTest(myClip) {
if (myClip.hitTest(targetSpot_mc)) {
myClip.onTarget = true;
} else {
myClip.onTarget = false;
}
}
//
// move movieClip to target pos.
function moveToTarget(myClip) {
myClip._x -= (myClip._x-targetX)/speed;
myClip._y -= (myClip._y-targetY)/speed;
}
//
// move movieClip to start pos.
function moveToStart(myClip) {
myClip._x -= (myClip._x-myClip.homeX)/speed;
myClip._y -= (myClip._y-myClip.homeY)/speed;
}
//
// button 1
home_mc.onMouseDown = function() {
mousePressed = true;
};
home_mc.onMouseUp = function() {
mousePressed = false;
};
home_mc.onPress = function() {
startDrag(this, false, left, top, right, bottom);
};
home_mc.onRelease = home_mc.onReleaseOutside=function () { stopDrag();targetTest(this);};
home_mc.onEnterFrame = function() {
if (mousePressed == false && this.onTarget == false) {
moveToStart(this);
} else if (mousePressed == false && this.onTarget == true) {
moveToTarget(this);
}
};
//
// button 2
info_mc.onMouseDown = function() {
mousePressed = true;
};
info_mc.onMouseUp = function() {
mousePressed = false;
};
info_mc.onPress = function() {
startDrag(this, false, left, top, right, bottom);
};
info_mc.onRelease = info_mc.onReleaseOutside=function () { stopDrag();targetTest(this);};
info_mc.onEnterFrame = function() {
if (mousePressed == false && this.onTarget == false) {
moveToStart(this);
} else if (mousePressed == false && this.onTarget == true) {
moveToTarget(this);
}
};
code on drag clips button 1 and 2:
onClipEvent (load) {
// initialize start position
homeX = this._x;
homeY = this._y;
}
thanks in advance and big thanks to everyone on this forum as its a godsend for getting your head round flash.
[AS] Drag And Drop; Return To Original Pos.
Hi, if anyone can help with this as its driving me nuts! Trying to build a drag and drop navigation, all the drag and drop works great, the test for the hit works ie if its on the target it centers the drag clip over the target, if its of the target the drag clip returns to its start postion. What I cannot get right is the code to check if the target already has a clip on it, if it has that clip needs to return to its start position, so we only ever have one drag clip on the target.
code timeline:
//
// initialize vars
left = 10;
right = 500;
top = 10;
bottom = 380;
speed = 10;
targetX = targetSpot_mc._x;
targetY = targetSpot_mc._y;
//
// test movieclip position
function targetTest(myClip) {
if (myClip.hitTest(targetSpot_mc)) {
myClip.onTarget = true;
} else {
myClip.onTarget = false;
}
}
//
// move movieClip to target pos.
function moveToTarget(myClip) {
myClip._x -= (myClip._x-targetX)/speed;
myClip._y -= (myClip._y-targetY)/speed;
}
//
// move movieClip to start pos.
function moveToStart(myClip) {
myClip._x -= (myClip._x-myClip.homeX)/speed;
myClip._y -= (myClip._y-myClip.homeY)/speed;
}
//
// button 1
home_mc.onMouseDown = function() {
mousePressed = true;
};
home_mc.onMouseUp = function() {
mousePressed = false;
};
home_mc.onPress = function() {
startDrag(this, false, left, top, right, bottom);
};
home_mc.onRelease = home_mc.onReleaseOutside=function () { stopDrag();targetTest(this);};
home_mc.onEnterFrame = function() {
if (mousePressed == false && this.onTarget == false) {
moveToStart(this);
} else if (mousePressed == false && this.onTarget == true) {
moveToTarget(this);
}
};
//
// button 2
info_mc.onMouseDown = function() {
mousePressed = true;
};
info_mc.onMouseUp = function() {
mousePressed = false;
};
info_mc.onPress = function() {
startDrag(this, false, left, top, right, bottom);
};
info_mc.onRelease = info_mc.onReleaseOutside=function () { stopDrag();targetTest(this);};
info_mc.onEnterFrame = function() {
if (mousePressed == false && this.onTarget == false) {
moveToStart(this);
} else if (mousePressed == false && this.onTarget == true) {
moveToTarget(this);
}
};
code on drag clips button 1 and 2:
onClipEvent (load) {
// initialize start position
homeX = this._x;
homeY = this._y;
}
thanks in advance and big thanks to everyone on this forum as its a godsend for getting your head round flash.
Drag Clip & Button To Send It Back To Original Position
I have a draggable movie clip that I've dragged and dropped at a random position on the stage.
I don't want it to snap back into place.
Does anyone know how I would code a button to tween it from that (random) spot back to it's original spot?
Thanks a lot in advance!!!
Pete
Drag Clip & Button To Send It Back To Original Position
I have a draggable movie clip that I've dragged and dropped at a random position on the stage.
I don't want it to snap back into place after it's dropped.
Does anyone know how I would code a button that would tween it from that (random) spot back to it's original spot?
Thanks a lot!!!
Pete
Drag Clip & Button To Send It Back To Original Position
I have a draggable movie clip that I've dragged and dropped at a random position on the stage.
I don't want it to snap back into place after it's dropped.
Does anyone know how I would code a button that would tween it from that (random) spot back to it's original spot?
Thanks a lot!!!
Pete
Make Drag N' Drop Snap Into Place
I am wondering if anyone has the code to make my drag and drop movie clip "snap" into place when it roles over another (given) movie clip.
Here is the code that I am using so far. It is located on an invisible button inside the movieclip which is being dragged in the main time line:
on (press) {
startDrag ("");
}
on (release) {
stopDrag ();
if (_droptarget eq "/one") {
gotoAndStop ("p1");
} else if ( _droptarget eq "/two") {
gotoAndStop ("p2");
} else if (_droptarget eq "/three") {
gotoAndStop ("p3");
} else if (_droptarget eq "/four") {
gotoAndStop ("p4");
} else {
gotoAndStop ("p5");
}
}
If this is not clear, please let me know. I am getting desperate, and can't find a tutorial with a clear answer.
Thanks. Gabrielle
Drag And Drop Snap Back Problem
I am developing a game where the player drags and drops words on to certain areas, if the word is placed on to the wrong area the word snaps back to its original place. But when you click on a correctly placed word in also then snaps back to its original place. I am using the normal startDrag and stopDrag commands on press and release.
Has anyone had this problem and is it correctable?
Cheers Astronaut100
Drag/drop Dublicates From Scrolling MC And Snap To Other MC
Hey Folks!
this is a MAD one, but could be really SWEET if it became OO!
1. We have a MC that scrolls several MC's up/down depending on _ymouse, no problem! got the scripts from this and made it vertical.
2. We want to drag/drop instances/dublicates of each of the several MC's to snap to specific locations where to it must snap and be independent from the scroller.
3. We want to be able to move the instances/dublicates between the specific locations. similar to this but where the grid is relpaced with MC's as droptargets.
the problem is partly solved
- but in a buggy, nonObjectOriented, embarrasing, 500-line long script wich i'll attatch later (if it really is nescesary, it's MAD!).
it's for a school-prototype, so it need the major functionality by sunday.
.neonleif
Drag And Drop Objects That Snap Into Place
Hello! I'm new around these parts (I literally signed up about 3 minutes ago!). I'm a high school student who just started using Flash about a month or two ago, so I'm far from advanced, though I have tackled some of the basics. In class I'm working on an art portfolio site but in my spare time I'm making a virtual dress-up doll (you know, the kind where you can pick up the clothes and drop them on the figure to mix and match outfits). Learning how to make drag-and-drop objects was very easy and there are lots of tutorials on it but what I can't figure out is how to get objects to "snap" into place. I want it so that the doll's hairdo's snap into position because they look kind of stupid when placed incorrectly.
Thank you so much, to anyone who can help! I've looked everywhere but haven't been able to find a tut on this >_<.
Drag And Drop Buttons - Snap Back Problem
Hi,
I have a drag and drop interactivity with buttons instead of MC's as I thought it would be simpler.
There is one button named "button" and 4 drop targets named "droptarget1", "droptarget2" etc.
I've used a for loop to test if the button should snap to a target.
It works fine except that when I add an else statement to snap back to it's original position,
it always snaps back to the original position, not just when it is outside the droptarget regions.
Does anyone know why this is? Here's the action attached to the button whose instance name is "button".
I've commented out the else statement that causes the error.
code: on (press)
{
startDrag(button);
}
on (release)
{
stopDrag();
for (i=1; i<5; i++)
{
if ( Math.sqrt (Math.pow(button._x - getProperty(["droptarget"+i], _x), 2) + Math.pow(button._y - getProperty(["droptarget"+i], _y), 2)) <20 )
{
button._x = getProperty(["droptarget"+i], _x) ;
button._y = getProperty(["droptarget"+i], _y) ;
}
//else {button._x = 300 ;
// button._y = 285 ;}
}
}
Drag And Drop To Grid With Snap To And Text Handles
Hi Everybody,
I'm tackling a new project and I can't figure out where to start! The app allows the user to drag images from a libray onto a grid and position the elements within the grid. The user can also drag textfields which can be edited and resized.
The grid needs to have some sort of snap-to, to make it easier for the user to line up the elements. And then I need to create resize handles around both the editable text fields and the other mc's. Has anyone seen a tutorial or can anyone help me with?
1. Drag and drop with a snap to grid
2. Resize handles for mc's, and inparticular textfields
In the end, I need to be able to track all of the x and y's of the elements on stage and then be able to rebuild their layout when it is loaded in a subsequent session. I'm sure this is going to be difficult. What do you think?
Brook
How To "snap Back" A Drag And Drop On Release?
I want to be able to create a drag and drop button without the "Drop" part.
When you release the mouse I want the item to snap back to it's original position.
This is the actionscript I have for the regular drag and drop:
on (press) {
startDrag("btn_01")
}
on (release) {
stopDrag()
}
Thanks for any help.
Character Position - Drag & Drop
I am trying to create a drag and drop interaction where a draggable item would be dragged and then dropped onto specific characters in a text field.
Is there a way to determine if something is released over specific characters of a text field, or a way to determine the x & y cordinates of a specific characters in a text field?
I'd normally do this by positioning a target MC over the specific text, and then use
eval(this._droptarget) == (targetMovieClip)
to determine if the item was released in the proper place, but I'm making a bunch of these, and am trying to do it dynamically, so I won't know where to position the targetMCs.
thx.
[MX] Drag & Drop To Correct Position?
Hi there,
I am newish to flash. I am using flash mx so i think it would be action script 2.0.
I want to create a simply action where I can drag an oject / shape to a postion on the document, if it is the correct position it stays there is not a message appears or it bounces back to where it was. Can someone please help me?
Joe
Drag And Drop Position After Dropped
Just trying to add a little more functionality to this code for a drag and drop interaction. Suppose I have multiple objects to drag and some will have the same target. Right now (with this code), the draggable object gets positioned in the center of it's target so my draggalbe movieclips will overlap eachother once they're dropped on the correct target.
What I'd like to do is prevent this overlapping and have the movieclips slightly offset on the y axis so they cascade a bit. Could do this by writing out alot of code for the individual movieclips but i'd like to condense it a bit. Any thoughts?
Code:
function dragSetup(clip, targ) {
clip.onPress = function() {
startDrag(this);
this.beingDragged = true;
};
clip.onRelease = clip.onReleaseOutside=function () {
stopDrag();
this.beingDragged = false;
if (eval(this._droptarget) == targ) {
this.onTarget = true;
trace("on targ");
} else {
this.onTarget = false;
trace("not on targ");
}
};
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;
clip.myFinalX = targ._x;
clip.myFinalY = targ._y;
clip.onEnterFrame = function() {
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/5;
this._y -= (this._y-this.myHomeY)/5;
} else if (!this.beingDragged && this.onTarget) {
this._x -= (this._x-this.myFinalX)/5;
this._y -= (this._y-this.myFinalY)/5;
}
};
}
dragSetup(circle_mc,targetCircle);
dragSetup(circle_mc2,target2);
dragSetup(circle_mc3,target2);
Reset Position Of Drag And Drop Game
I'm creating a "dressing up" game using the drag and drop functionality, however I would like to add a reset button that returns all the clothes to their original postion. Is there an effiecent way to code this?
Drag And Drop - Moviclip Moving Back To Old Position
Hi Guys
I am learning to do a drag and drop, basically say I got A movieclip called 'clipdrag'. the current position of the movie clip is _x=65, _y=51.
and the clipdrag movieclip is droped at say _x=200, _y=300.
Bascally what i need to know is how i got about bring the clip back to its orangial position, i want to use a timer so that the user can see the clip moving back slowly.
please can anyone help
thanks
orange
Drag And Drop - Moviclip Moving Back To Old Position
Hi Guys
I am learning to do a drag and drop, basically say I got A movieclip called 'clipdrag'. the current position of the movie clip is _x=65, _y=51.
and the clipdrag movieclip is droped at say _x=200, _y=300.
Bascally what i need to know is how i got about bring the clip back to its orangial position, i want to use a timer so that the user can see the clip moving back slowly.
please can anyone help
thanks
orange
Drag And Drop "snap To"
Hi all, I'm working on this sliding bar navigation thing , and I'd like to make the bar "snap to" certain points along the line. Does anyone know how to do that?
p.s.... yeah i know I need a preloader!
Timeline Window Won't Snap Back To It's Original Place
Hi all,
I'm having the most annoying, and the most weirdest problem ever. Has anyone had problems with the timeline window where it just don't snap back into it's original place, that is, just above the workarea? After a few times using flash with it's timeline window detached from it's original spot on a dual monitor, the timeline window always start detached when loading a fla document, or when creating a new document, and it just won't fit back into it's original place unless I choose to load up a pre-saved panel set.
Please! if anyone had or knows about this problem please let me know what to do! I don't want to go over the hassles of reinstalling and reseting all my personal settings! grRR!
Drag & Drop - Animating A Dropped Object To Start Position
How can I make my drag and drop exercise so that when a dragged object is released, it goes back to its start position by animating back to it? I know how to script this so that it instantly snaps back to the start position, but I would like the user see the object move back to its start position.
My flash project can be downloaded from:
http://www.munzamedia.co.uk/flash/
Note: only the two top-left objects can be dragged.
Reset Movie Clip X-position & Y-position Back To Original
Is there a command to reset x-position, y-position and rotation all at once...like reset command?...or would I have to find the original x-positions and y-positions to all elements and hardcode that back....EEEK!!
Many Thanks
Andrea
Original Position
is there any way to set a movie clip back to its original position (say if it was dragged)? without using its coordinants? is there like a command or something? like....mc.setProperty._x,_y.original
or something?
Bck To It's Original Position
I have a series of buttons,i can drag and drop them, but i need them to go back to their original position if they hit their first position...
Code:
fscommand("fullscreen", true);
fscommand("allowscale", false);
Stage.showMenu = false;
stop();
//------------Start buttons functions------------------------
var buttons:Array = new Array({instance:btn_01}, {instance:btn_02});
//------------Start movie proprieties------------------------
onEnterFrame = function () {
for (var k:Number = 0; k<buttons.length; k++) {
buttons[k].instance.onPress = function() {
this.startDrag();
this.onEnterFrame = function() {
btn_text.text = "X = "+(50/circle_mc._width)*this._x+" %";
btn_text2.text = "Y = "+(50/circle_mc._height)*this._y+" %";
};
};
buttons[k].instance.onRelease = buttons[k].instance.onReleaseOutside=function () {
this.stopDrag();
released = true;
this.onEnterFrame = function() {
if (this.hitTest(_root.circle_mc)) {
this.gotoAndStop(2);
} else {
if (this.hitTest(_root.menu_bkg)) {
this.gotoAndStop(1);
}
}
};
};
}
};
How'd U Make An Object Snap 2 Its Original Pos On An Object Thats Moved?
I'm working on a school project using Flash mx that needs a scrolling inventory. I know how to get an object to snap back to its original position from a drag, but how would you get it to snap back to its original position on an object that has moved? ie. On a scrolling menu?
//script to have a spanner remove a head and snap back to position if it doesn’t touch the head on release:
//attach to object
onClipEvent (load) {
spanx = _root.spanner._x;
spany = _root.spanner._y;
}
//action inside clip
on (press) {
startDrag(this,true);
}
on (release, releaseOutside) {
if (this.hitTest(_root.dismantle.head) & _root.head_switch=="hollow") {
_root.spanner.gotoAndPlay(2);
_root.dismantle.head.gotoAndPlay(2);
this._y = 185;
_root.airbrush._x= _root.airbrush.airbx;
_root.airbrush._y= _root.airbrush.airby;
}
else {
_root.spanner.gotoAndStop(1);
this._x = spanx;
this._y = spany;
this.gotoAndStop(2);
}
stopDrag();
}
how would i script a scrolling inventory from which I can drag and drop objects that snap back to the same pos in the inventory even tho its moved? You can see the inventory on the right of the attached jpeg.
Snap Into Position OH THE PAIN
Hi,
I know its probably easy to do but after 3-4 hours of reading different bits on the net, i still can't get this to work. I would like to get the first movie clip to snap to the target and then play another movie clip. It all works except the snap.
Help please!
Could you explain if possible what the different parts of the code do, as i am interested in learning not just having someone do it for me!
thanks
Webby
Code on the button within the dragable movie clip:
on (press) {
startDrag("_root.drag1");
}
on (release) {
stopDrag();
if (_root.drag1._droptarget == "/test1") {
_root.outline1.gotoAndStop("done");
}
}
Easing And Original Position ~_~
ok.. I gave up ~_~
I want to make an easing effect on mouse follow over the Y axis... well, this was easy.. thanks to Kirupa's tutorial.. but.. lets say, I want the object to go back to its original position when the mouse rolls out.... it might be a rollOut statment.. but dunno how the AS should be look like
Any suggestions?
Thanks
OniHime
Trying To Replace Mc On Their Original Position
OK here it is:
im doing a drag and drop quiz in as2, and so far it all works, except the Reset function which is suposed to replace all of the numbers on their original position. Here is the function that at the begining of the frame stores in two arrays the original positions of all the numbers:
Code:
function posInitiale() {
for (j=0; j<=target1.length; j++){
arrayPosX.push(_root[target2[j]]._x);
arrayPosY.push(_root[target2[j]]._y);
}
}
It works, when I do a trace of the them, I get something like this:
569.95,570,570,570,570 <-- X
232.65,280.7,328.7,376.7,424.7 <-- Y
When I press the Reset button, it executes the function that is suposed to reponsition them on their original position. Here is the function:
Code:
function replacer() {
for (g=0; g<=target1.length; g++){
_root[target2[g]]._x = Number(_root.arrayPosX[g]);
_root[target2[g]]._y = Number(_root.arrayPosX[g]);
}
}
This, doesnt work, it replaces all of the outside of the scene of flash, if you open the swf bigger you will see them at the bottom of the screen, and they are all on top of each other. But again, if in this function I trace both the arrays I still get the same result, which are the correct position they should go on. I have no clue why it does this...
I have attached my files.
Thank you in advance for the help!
Carl
Snap To Position Movie Clips
Anyone got any suggestions for this.
In my flash file i have a draggable MC, what i want to happen is when the MC is stopped being dragged that is it is within a X and Y co-ordinates range it snaps to a specific X and Y co-ordinate.
please help.....driving me mad.
I Don't Even Know What It's Called - 'snap To Position' Behaviour
You know the sort of thing... drag an instance around in a random fashion, when it gets to the right place, on mouse release, it snaps neatly into a pre-specified position...
I'm not asking 'howzat dun then?'. I don't even know what the technique is called [or what aspect of actionscript controls the action]!
All I want to do is to know what actionscript terms to use, so I can go search out the method [ok, any pointers *would* be appreciated at this stage]...
Thanks!
Snap Objects To Desired Position?
What I'm basically trying to do is use the snap feature in flash during runtime.
I have a diagram of a rack that holds all of our servers, switches, etc and a bunch of pictures of the different models in flash. I want to be able to drag the pictures and have them snap into a place in the rack so anyone could reconfigure it very easily.
I was just wondering if anyone could explain how this might be done, or if anyone had seen anything like this I could download or take a look at.
I think it could also be done using DHTML.
Thanks for any input.
Making Images Snap To A Position.
How do I make an image be dragable to a space and then when dropped it snaps to the space.
I want to be able to do this with a series of images in a quiz so that when you have the images arranged in the right order it tells you it is correct.
Ease Back To Original Position AS?
Hi, Flashkit'ers.
I'm working on a photo gallery in which a thumbnail of a larger image can be dragged and dropped at a hitarea, then the larger image loads. I have the whole drag, drop and load down just fine. But what im having problems is having the thumbnail, being dragged, ease back to its original position if it's not dropped on the hitarea. Here is my AS so far (minus the easing AS of course ):
Code:
on (press) {
startDrag(btn1);
}
on (release) {
stopDrag();
if (eval(this._droptarget) == _parent.dropArea) {
this._visible = 0;
_parent.btn2._visible = 1;
_parent.btn2._x = 124;
_parent.btn2._y = 344;
_parent.contents.loadMovie("pic0.swf");
} else {
this._x = 74;
this._y = 344;
}
}
I know there is an easy way to easing, i just can't seem to figure it out. Any ideas? thankyou
takecare.
|