Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 3rd, 2008, 10:58 AM
Newbie
 
Join Date: Sep 2008
Posts: 1
Default Drag n Drop using arrays for multiple movieclips

Can any one help me how to do drag and drop for multiple movie clips which are inserted dynamically. (Like match the following for example For question A (which is in lift side of the stage) answer is B5(which is in right side of the stage)). When i drag the question A line should be generate from the the drag position. Please check the code attached with this.

[code]...

a = 0;
b = 0;
depth = 1000;
for (i=0; i<6; i++) {
if (i<3) {
var box_mc = "box_mc"+i;
_root.attachMovie("box_mc", box_mc, depth++);
a++;
eval(box_mc)._x = 100;
eval(box_mc)._y = 50*a;
} else {
var rbox_mc = "rbox_mc"+i;
_root.attachMovie("rbox_mc", rbox_mc, depth++);
b++;
eval(rbox_mc)._x = 200;
eval(rbox_mc)._y = 50*b;
}
}
xArray = new Array("box_mc0", "box_mc1", "box_mc2");
yArray = new Array("rbox_mc3", "rbox_mc4", "rbox_mc5");
this.createEmptyMovieClip("line_mc", this.getNextHighestDepth());
var flag = false;
for (i=0; i<=2; i++) {
eval("box_mc"+i).onPress = function() {
startDrag(this);
//trace(this);
this.swapDepths(depth++);
posX = this._x;
posY = this._y;
eval("box_mc"+i).onEnterFrame = function() {
if (flag == true) {
line_mc.lineStyle(1, 0x000000, 100);
line_mc.moveTo(posX, posY);
line_mc.lineTo(this._x, this._y);
}
};
};
posX = this._x;
posY = this._y;
flag = true;
eval("box_mc"+i).onRelease = function() {
this.stopDrag();
//trace(this);
delete eval("box_mc"+i).onEnterFrame;
if (eval(this._droptarget) == ("rbox_mc"+i)) {
} else {
this._x = posX;
this._y = posY;
}
};
}

But i am not able to trace the value of ("rbox_mc"+i).
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles