View Full Version : urgent help with a counter....
fault151
October 7th, 2007, 08:59 AM
Hi, guys and gals. I really need to get this flash counter working. I just cant seem to get the code in the right place. I'd really appreciate it if some flash guru could take a quick look for me. I gotta get this thng working for tomorrow. Please help me if you can!
Thank you :wt:
Download the FLA at the following link:
http://www.fault151.com/blogspot/supermarket.fla
fault151
October 7th, 2007, 10:49 AM
I'm extremely desperate for help with this one! Please respond if you can.
Thanks a lot!!!!!
:beam:
sepu
October 7th, 2007, 11:51 AM
Copy ur code I'm on my touch dont have a computer with me right now and I can't open flash with the touch.... I wish I could though (-:
fault151
October 7th, 2007, 12:14 PM
Hey, thanks for your reply. Here is the code:
[CODE]var counter:Number = 0;
function dragSetup(clip, targ) {
if(counter == 15){
reply_txt.text = "Congratulations, you're finished!";
}
clip.onPress = function() {
startDrag(this);
this.beingDragged=true;
};
clip.onRelease = clip.onReleaseOutside=function () {
stopDrag();
this.beingDragged=false;
if (eval(this._droptarget) == targ) {
this.onTarget = true;
reply_txt.text="You got it!";
} else {
this.onTarget = false;
reply_txt.text="No, keep trying!";
}
};
//the variables below will store the clips starting position
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;
//the variables below will store the clips end position
clip.myFinalX = targ._x;
clip.myFinalY = targ._y;
clip.onEnterFrame = function() {
//all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
// then move the MC back to its original starting point (with a smooth motion)"
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/5;
this._y -= (this._y-this.myHomeY)/5;
//if the circle is dropped on any part of the target it slides to the center of the target
} else if (!this.beingDragged && this.onTarget) {
this._x -= (this._x-this.myFinalX)/5;
this._y -= (this._y-this.myFinalY)/5;
}
};
}
dragSetup(bag1_mc,targetbag);
counter++;
dragSetup(bag2_mc,targetbag2);
counter++;
dragSetup(bag3_mc,targetbag3);
counter++;
dragSetup(bag4_mc,targetbag4);
counter++;
dragSetup(bag5_mc,targetbag5);
counter++;
dragSetup(bag6_mc,targetbag6);
counter++;
dragSetup(bag7_mc,targetbag7);
counter++;
dragSetup(bag8_mc,targetbag8);
counter++;
dragSetup(bag9_mc,targetbag9);
counter++;
dragSetup(bag10_mc,targetbag10);
counter++;
dragSetup(bag11_mc,targetbag11)
counter++;
dragSetup(bag12_mc,targetbag12);
counter++;
dragSetup(bag13_mc,targetbag13);
counter++;
dragSetup(bag14_mc,targetbag14);
counter++;
dragSetup(bag15_mc,targetbag15);
counter++;[CODE]
sepu
October 7th, 2007, 12:29 PM
what is exactly wrong with this? you said the counter .... more info please
fault151
October 7th, 2007, 12:38 PM
what is exactly wrong with this? you said the counter .... more info please
The whole fla is a design for a drag and drop exercise.
Basically the counter wont add up proprely. I can't see why. I have 15 objects that move on to target areas. For example if you drag one of the objects in to the correct target area it adds one to the total. When all 15 objects are in the correct target palece, it alerts thhe viewer to let them know thay have succesfully completed the course. I cant get the counter to add up the items properly.
Hope this helps!
RubenFlash
October 7th, 2007, 01:57 PM
Your dragSetup function is being called only when the movie loads. You must call it each time a drag operation concludes in order to update your counter.
fault151
October 7th, 2007, 02:19 PM
Your dragSetup function is being called only when the movie loads. You must call it each time a drag operation concludes in order to update your counter.
First of all, thanks for your reply! I'm not sure i know how to do that. Do you have an example of it that i could look at please?
sepu
October 7th, 2007, 06:13 PM
when I trace counter I get an undefined .... because is AS 1 change the settings to AS2 that will trace 15 .......
fault151
October 8th, 2007, 05:24 AM
when I trace counter I get an undefined .... because is AS 1 change the settings to AS2 that will trace 15 .......
I don't know what you mean? How do i change it to AS2?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.