I have simple Drag n Drop interactivity in my flash movie. There are draggable objects to be dropped on their targets. If they reach the desired Target they stick to that target. If the object does not reach its target, it snaps back to its original x,y location.
The code is here:
{
if (this._droptarget == "/something") {
this._x = _root.something._x;
this._y = _root. something._y;
_root. somethingM.gotoAndPlay(1);
}
else{
this._x = 440;
this._y = 320;
}
}
Two things:
How can I randomize the location of the objects, and then essentially capture that location and plug it dynamically into the code above?
And how can I randomize the location of the targets for those objects to be dropped onto?
(And I suppose an additional question would be, so I don’t hide any content, how do I do this without overlaying the objects and targets on top of each other?)
Any help is greatly appreciated, thanks.
Anyone have thoughts on randomizing the draggable objects in a drag N drop? After randomization, their X, Y coordinates need to be recorded and plugged in to the drag drop code, so they know where to snap back to if they are NOT dropped onto their targets.
Think of it this way, pretend I’m making a jigsaw puzzle and the pieces get mixed up at first, and therefore have new initial x,y coordinates.
How could I do this, to randomly mix the pieces on the board, and then capture the x,y coordinate of that random position to plug in to my code?
This is the code in the drag n drop function that snaps the piece back to its original position if its not placed in the correct drop target:
else{
this._x = 440;
this._y = 320;
The x=440 and y=320 would be randomly generated in the beginning and then plugged into this statement.
-
How do I randomly mix the objects on stage up?
-
How do I capture their randomly generated x,y coordinates and place it into the code above?
Thanks.