-
Drag and Drop Objects with Line Between
Hey all, I'm new here.
I was wondering if there was anyway to put a line between two or more dragable objects...
The only example I can think of is metroidprime.com.
Thanks,
Adanufgail
-
Senior Member
Maybe you need to draw a picture then, cause I'm really not sure what you're asking for...
-
Basicly I'm looking for a way to have objects be draggable but keep a line (which I guess could be an object too) stretched in between them.
-
Senior Member
This is a frame script. It assumes the blue square and the green square are movieclips that have been assigned the names mc1 and mc2.
If you want the lines to issue from a particular corner, orient the movieclips so that the crosshairs correspond to that corner.
I prefer to have the lines issue from the center (so I keep the crosshair centered).
code:
_root.createEmptyMovieClip("line_mc", 1);
MovieClip.prototype.drawLine = function()
{
this.clear();
this.lineStyle(2,0xFF0000,100);
this.moveTo(mc1._x, mc1._y);
this.lineTo(mc2._x, mc2._y);
}
// insure movieclips are in front of line
mc1.swapDepths(2);
mc2.swapDepths(3);
// draw initial line
line_mc.drawLine();
mc1.onPress = mc2.onPress = function()
{
this.startDrag();
line_mc.onEnterFrame = drawLine;
}
mc1.onRelease = mc2.onRelease = function()
{
delete line_mc.onEnterFrame;
this.stopDrag();
}
-
Yay! Thanks!
I tried to put a button inside the movie clip, but it doesn't seem to work...Any ideas?
-
Senior Member
You tried to put a button inside which movieclip? The line?
Did you get the basic line drawing and dragging to work?
-
I got the basic line/drag to work.
I tried to put a button in the mc movieclip. I'm basicly building this little web of related items and when you click on an item, it pops open a window.
-
Also, while I'm asking,
Is there anyway to get a movie clip (one that looks like a book, which I've designed already) to pop up after a button press and based on which button it is, put a specific text file in the book?
-
</hate>
How would I go about modifying this code to handle four MCs? I'm imagining something that looks like dragging walls in a room where each MC is a corner of the room. Does that make sense? mc1 connects to mc2 which connects to mc3 which connects to mc4 which connects to mc1 again. Thanks for your help!
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|