View Full Version : drag counter
i want to trace() the number of mc's i drop into another mc, but i dont know how to make it, because the counter i made also counts...mouse clicks!
here's my code:
------------------------------
onClipEvent(mouseUp) {
if (this.hitTest(_root._xmouse,_root._ymouse,false)) {
var v;
v++;
trace(v);
}
}
-----------------------------
farafiro
04-01-2002, 06:29 AM
So what u want the counter to count, mouse click or the mc hits .... or both??
want the number of mc drops, not mouse clicks
red penguin
04-01-2002, 01:45 PM
Thought it'd be easier to just make a file than to explain it...
The jist of it goes like this...You have your draggable clip. On the release of it, you test to see if it is on the target..if it is, then you increase a counter variable by one...I made one clip, duped it and randomly placed it....
Take a look at the file and post any other questions if you don't follow...
thanks a lot, that's just what i wanted!
tested yours (amusing display) and also with my own movie;
now for the doubts:
1)
if(this.hitTest("_root.target")){
_root.target means not the mouse but the mc onto we drag, right?
2)
why adding _root to the var dropcounter?
3)
_root.target.output=_root.dropCounter;
why .output?
anyway thanks again
red penguin
04-01-2002, 03:01 PM
1. Yes. It's what we are testing for the hit in string format.
2. dropCounter is declared on the _root, so there it exists and there we must target it.
3. Output is the name of the textField which is in the target clip.
chralm
02-25-2003, 02:53 PM
I would like to replace the dups with actual MC's with different names.
I have this:
MC's:
heart
leg
arm
lungs
when I've draged them to the target then finished.
How do I rename the clips that you've got in your example?
red penguin
02-26-2003, 02:30 PM
MX it up:
arr_clips=['mov_lungs','mov_heart','mov_arms','mov_legs'];
int_clips=arr_clips.length;
for(i=0;i<int_clips;i++){
this.attachMovie(arr_clips[i],arr_clips[i],i);
this[arr_clips[i]]._x = random(400);
this[arr_clips[i]]._y = 50;
this[arr_clips[i]]._xscale = this[arr_clips[i]]._yscale = 50;
this[arr_clips[i]].onMouseDown=function(){
if(this.hitTest(_root._xmouse,_root._ymouse,false) ){
this.startDrag();
}
};
this[arr_clips[i]].onMouseUp=function(){
this.stopDrag();
if(this.hitTest("_root.target")){
_root.dropCounter++;
_root.target.output=_root.dropCounter;
this.removeMovieClip();
if(_root.dropCounter==int_clips){
_root.msg="You've collected them all..."+newline+"That wasn't too hard now, eh?";
}
}
};
}
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.