Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Comparison between a value with static type String and a possibly unrelated type Number

Community Beginner ,
Nov 26, 2022 Nov 26, 2022

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();

 

 

334
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2022 Nov 26, 2022

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 26, 2022 Nov 26, 2022
LATEST

It isn't easy to tell which line is 20, also, what is the value of F?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines