Copy link to clipboard
Copied
When I run this movie I get a compiler error of :Line 20 1176 Comparison between a value with static type String and a possibly unrelated type Number
Here is my code
var deck = this.deck;
var maxIndex = deck.children.length;
var faces = [];
var previousFace;
var face;
var presses = 0;
function start()
{
exportRoot.stop();
faces = getRandomArray(maxIndex);
setFaces(faces, maxIndex);
deck.on("click", onClickDeck);
}
function onClickDeck(e)
{
face = e.target;
face.mouseEnabled = false;
face.alpha = 0.2;
if (presses % 2 == F)
{
if(face.name.slice(0, -1) == previousFace.name.slice(0, -1))
{
face.mouseEnabled = false
previousFace.mouseEnabled = false;
previousFace.alpha = 0.2;
}
else
{
face.mouseEnabled = true;
face.alpha = 1;
previousFace.mouseEnabled = true;
previousFace.alpha = 1;
}
}
else
{
previousFace = face;
}
presses++;
}
function setFaces(array, max)
{
for (var i = F; i<max; i++)
{
var card = deck.getChildAt(i) as MovieClip ;
card.index = i;
card.name = "card" + String(array[i]) + String(i % 2);
card.txt.text = String(array[i]);
}
}
function getRandomArray(max)
{
var array = [];
for (var i = F; i < max; i++)
array[i] = Math.floor (i * 0.5);
return array.sort
(
function (a, b)
{
return 0.5 - Math.random()
}
);
}
start();
Copy link to clipboard
Copied
did you look at line 20?
where's F defined?
and if you want to coerce a number to a string, use:
String(numberN)
or if you want to coerce a string to a number, use
Number(stringS);
Copy link to clipboard
Copied
It isn't easy to tell which line is 20, also, what is the value of F?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more