If anyone has time could you PLEASE look at the code below (I've also attached the fla file). I've made a drag and drop game which works but the incremental score won't work. I've only placed code on this draggable object. (Thought I'd try to get one working before I messed up the lot.) As you can see from the comment lines I've tried a lot of code options but none will work.
I'm a complete novice so I greatly appreciate any help given.
Thanks
PHP Code:
on(press) {
startDrag(this);
//on mouse up drag object
}
on(release) {
stopDrag();
//on mouse down drop oject
if (this._droptarget == "/innerCoreTarget") {
// if the draggable oject is dropped onto the correct target
this._visible = false;
// make the draggable object disappear
_root.innerCoreCorrect._visible = true;
// make the target picture visible
mouseSound = new Sound(this);
mouseSound.attachSound("clickwav");
mouseSound.start();
//play a sound effect of the object snapping into place
_root.checkbox5.gotoAndStop(2);
// display a correct tick in the score box
//updateScore();
}
else{
// if the draggable object is not placed on the correct target
this._x = 444;
this._y = 137;
// move the draggable object back to its pre dragged position
_root.checkbox5.gotoAndStop(1);
// don't display the correct tick
Problem is that you need to Embed your font to your textfield(s). Simply click on your textfield, open Properties Panel, change from Bold to Regular, this is important, because embedding bold fonts doesn't work for some reason. Then, click on the Embed... button, and tick/check Numerals and press OK. Test your movie again with your different methods, and hopefully it should work, otherwise, here is a code of my own you can put on one of the frames on the Main Stage, and just type updateScore(); in the draggable movieclips (like you have for the Crust mc):
Actionscript Code:
_global.updateScore = function(){ score_var = 0; for(i=1;i<10;i++){ if(_root["checkbox"+i]._currentframe == 2){ score_var++; } } scorecounter.text = score_var; // or you can use this as well: // score = score_var; }
but instead of using updateScore(); inside the if statement which checks if the draggable movieclips are within their respective areas (for instance, if ((this._x>=269) & (this._x<=279) & (this._y>=182) & (this._y<=193)) {), use that code outside that function, right below on(release) part, otherwise the score will only be updated when any movieclip is placed on their corresponding correct areas.
What the code does, is that, since you've made 9 checkboxes with instance names which have a number which increase (doing this made you save some time), it runs a for loop (a loop which increases a variable), checking all the checkboxes's current frame, if any checkbox's current frame is equals to 2, meaning that a movieclip is correctly placed, it increases a variable (score_var) declared right before the for loop, and after the loop, the value of that variable (score_var) is the same as the number of correctly placed movieclips, and lastly it assigns that variable's value to your textfield (I've included two methods for doing that, the first targeting its instance name, while the second, its variable name, I think the second method is most appropriate and easiest method in this case, as it's good for scores and such similar incrementing number values)
Hope this helps
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
Thank you so much! The unembeded bold font was indeed the problem - I had no idea. Also your idea to link the update score to the tick checkboxes = frame 2 was genius. Also, as I'm a beginner to code, the explanation you gave was detailed, very clear and much appreciated - thank you.