A simple example: Creating a resetable score counter

As someone completely new to JavaScript I hope the attached wick file will help anyone else starting out and wanting to add scoring to a game.
I kept the demo file as simple as possible.
It is thanks to Luca’s tutorials, CosmicKnight1and Jovanny that I worked out how to script this simple file.
I hope it helps someone.

The next bit is for those of you who really are just starting to use the Interactive Wick Editor. and is very basic but not intuitive.

To view the script I used, when the demo isn’t running, click the topmost left tool in the wick screen, “the cursor”. Then click on a frame, button or clip to highlight it. move the mouse to the Inspector on the right of the wick screen. under scripts click on one of the black boxes which will be "DEFAULT, MOUSECLICK or KEYPRESS.
Each time you do this you will see the script.
For example:-
If you highlight the START page you will see under default the script: “stop(1)”
telling everything to stop on frame 1 and you will see under mouseclick script: "gotoAndStop(2)
telling the everything to move on to frame 2.
If you click on frame 1 there is nothing in the inspector under scripts because all the actions are set in the START page clip.

To see how the count is set: Highlight frame 2. under default script line two sets the starting score and line 3 makes it appear on the screen after the word Tokens.
Lastly highlight and click on the the word Tokens: In the inspector TEXT you will see the name “storeCounter” The name you give in the inspector is the name you must use in the button script.

So-- The starting number and the way it displays is set in the FRAME.

To see how the score is changed and how actions result: Highlight the minus button.
Under scripts in the inspector there is only the Mouseclick because that is all that will happen to this button. View the script:
Line 1 shows how the score is altered.
Change -=1 to -=2 and the score will jump up two for each button click. Change - to + and the button will become a plus button.
Line 3 sends the new value for" project.score" to the screen
Line 4 Sets the score value that will trigger an action ,in this case zero. If you were to reset the zero to 2 then at a score of 2 is when the action to move to frame 3 would occur.
Note: if ( this happens ) {do this}

So-- Any addition to or subtraction from the original number and actions taken are set in the BUTTON

GAME COUNTER + and -.wick (4.8 KB)