Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 定义为字符串的变量_Actionscript 3_Actionscript - Fatal编程技术网

Actionscript 3 定义为字符串的变量

Actionscript 3 定义为字符串的变量,actionscript-3,actionscript,Actionscript 3,Actionscript,当我尝试将此变量设为数字时,allMatches是一个数字,但其中的值作为字符串连接(例如,1、2和3作为123而不是6连接在一起) 所有统计数据值都是数字,在其他时间成功用作数字,但在此变量中,它们的行为类似于字符串。这是因为您将数字作为字符串存储在数组中。 您可以使用parseInt从字符串中获取数字 var allMatches:Number = soloStats[0] + duoStats[0] + squadStats[0] 嗯,你确定统计数组真的有数值吗?使用跟踪(getQual

当我尝试将此变量设为数字时,allMatches是一个数字,但其中的值作为字符串连接(例如,1、2和3作为123而不是6连接在一起)


所有统计数据值都是数字,在其他时间成功用作数字,但在此变量中,它们的行为类似于字符串。

这是因为您将数字作为字符串存储在数组中。 您可以使用
parseInt
从字符串中获取数字

var allMatches:Number = soloStats[0] + duoStats[0] + squadStats[0]

嗯,你确定统计数组真的有数值吗?使用
跟踪(getQualifiedClassName(soloStats[0])检查这一点。快速修复方法是转换如下值:
var allMatches:Number=Number(soloStats[0])+Number(duoStats[0])+Number(squadStats[0])const allMatches = parseInt(soloStats[0]) + parseInt(duoStats[0]) + 
parseInt(squadStats[0])