Reputation: 91
I'm trying to create a virtual keyboard.
I have a class VirtualKeyboard
which contains an array called keyboard of 26 movieclips, each one representing a letter.
In the main class, I create an object of the class VirtualKeyboard
and added an eventlistener
on it when a letter is clicked.
I tried this in the event handler:
var objectClicked:Object = event.currentTarget;
var index:uint = virtualKeyboard.keyboard.indexOf(objectClicked);
But the index
always returns the value 4294967295.
How can I know which letter was clicked, I mean the index in the keyboard array corresponding to that letter?
The same code is working correctly if I put it in the VirtualKeyboard
class, but not from the main class.
Upvotes: 0
Views: 250
Reputation: 82058
4294967295
is 2^32 - 1. That is what happens when you assign -1 to a uint
. It means the value was not found.
Recommendations:
virtualKeyboard.keyboard
an array of DisplayObjects, or is it an array of strings or numbers? You have to make sure you are comparing apples to apples, not apples to goats (Also why I recommend Vector).Upvotes: 3