0

Probably another easy one, but after hours of searching and trying I still cant get this working.

I have a keypad with 10 buttons (0 - 9) - I want to create a variable that stores the number of key presses on the keypad and displays each MC accordingly in sequence depending on how many presses have been made.

For example, if only 1 key has been pressed, then only the first MC displays (and increments the variable to '1'), if 2 keys have been pressed then the first and second MC's are displayed - and so on until all 4 of my MC's are displayed and the MC progresses to frame #33.

I am getting different errors depending on how I structure this (mainly "expecting identifier before greaterthan")

My code for button '0' is below, can anyone assist please?

kpad.b0.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown0);

var clickCount:int = 0;

function onMouseDown0(e:MouseEvent):int {

clickCount++();

if (clickCount <= 0)
    as1.visible = true;
if (clickCount == 1)
    as1.visible = true; 
if (clickCount == 2)
    as1.visible = true;
    as2.visible = true;
if (clickCount == 3)
    as1.visible = true;
    as2.visible = true;
    as3.visible = true;
if (clickCount == 4)
    as1.visible = true;
    as2.visible = true;
    as3.visible = true;
    as4.visible = true;
if (clickCount => 4)
    this.gotoAndPlay (33)
}
frltd
  • 13
  • 7
  • 2
    Use `if (clickCount >= 4)` ... not `if (clickCount => 4)` – VC.One Nov 02 '17 at 21:45
  • 1
    There are at least 4 errors. 1. The one VC.One mentioned. 2. What's the idea behind calling **clickCount++();** - it is an **int** value - as a function? 3. You are not using **{ }** brackets after **if** clauses. 4. Event listeners must be of **:void** type, not **:int** - they are not supposed to return anything. – Organis Nov 03 '17 at 05:45
  • 1
    And instead of multiple `if`'s, you should use [else if and else, or switch](https://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fce.html) statements. – kaarto Nov 03 '17 at 13:34

0 Answers0