Hi everyone/anyone
Even typing out the subject makes me think I have something intrinsically wrong…
I’m trying to create dragging functionality which starts onMouseDown and ceases onMouseUp, it’s part of a .fla that will be doing a number of other things so I won’t paste the whole lot as it will probably make what I need right now more convoluted.
So, this code…
[FONT=Courier New]parentPath = this;
//x&y placement for number of items
itemPos = [[10, 10], [40, 40], [70, 70], [110, 110], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150], [160, 160], [170, 170], [180, 180]];
createItems = function () {
for (i=0; i<itemPos.length; i++) {
parentPath.createEmptyMovieClip(“item_”+i, parentPath.getNextHighestDepth());
parentPath[“item_”+i].attachMovie(“item”, “item”, this.getNextHighestDepth());
parentPath[“item_”+i].x = itemPos*[0];
parentPath["item"+i].y = itemPos*[1];
//
parentPath["item"+i].onMouseDown = function() {
trace("mouseDown, this = “+this);
this.onEnterFrame = function() {
this._x = parentPath._xmouse;
this._y = parentPath.ymouse;
};
};
parentPath["item”+i].onMouseUp = function() {
trace("mouseUp, this = "+this);
this.onEnterFrame = null;
};
}
}
createItems();
[FONT=Verdana]…is what I have, when I run this (and have ‘item’ with ‘linkage’ set in the library) I get 18 items, with x,y co-ords as per the array, on the Stage. Then when i press down on any one item they all stack up under my mouse so that it appears i only have 1 item. All of the items move with my cursor and stop onMouseUp.
I figured that as I have [/FONT][/FONT][FONT=Courier New]parentPath[“item_”+i].onMouseDown = function(){}[/FONT][FONT=Courier New][FONT=Verdana] I would have 18 different items with 18 seperate mouseDown functions, but they all appear to depend on one another.
So how can I have all item_x’s have this functionality but not copy one another?
The only solution I can think of it to actually duplicate the onMouseUp and onMouseDown functions for every single item_x!!! This will work, but it cannot possibly be the most efficient way of executing this code…
Any help is appreciated and I swear I’ll buy you a drink if I ever meet you.
[/FONT][/FONT]