如何将数组和多维数组中的内容动态添加到文本字段?
我正在使用数组和多维数组开发交互式测验类型游戏。
我试图创建一个动态文本字段,说“当前问题”+“抱歉,正确答案是...”+“数组中第一个答案字符串中的第二个答案”。
我想我已经很接近了,但是语法上有错误。
这是我尝试执行此操作的代码行:
questionHolder.question.text=(String (cat4Questions[0]) + "Sorry, the correct answer is "+ String (cat4Answers[0,2]));
我收到此错误:
VerifyError: Error #1030: Stack depth is unbalanced. 1 != 0.
如果有人可以推荐我的语法的不同措辞以产生积极的结果,我会很高兴。
谢谢!格雷姆
I am working on an interactive quiz type game using arrays and multidimensional arrays.
I am trying to make a dynamic textfield say "the current question" + "Sorry, the correct answer is..." + "the second answer in the first string of answers in the array".
I think I am pretty close, but there is an error in the syntax.
Here is the line of code where I try to do this:
questionHolder.question.text=(String (cat4Questions[0]) + "Sorry, the correct answer is "+ String (cat4Answers[0,2]));
I am getting this error:
VerifyError: Error #1030: Stack depth is unbalanced. 1 != 0.
I would be happy if someone could recommend a different phrasing of my syntax that will yield positive results.
Thanks! Graeme
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题可能出在:
cat4Answers[0,2]
。访问多维数组的正确语法是 array[a][b] 而不是 array[a, b]。假设您的数组在索引 2 处包含问题 0 的正确答案,您可以像这样
cat4Answers[0][2]
访问该答案。The problem might be here :
cat4Answers[0,2]
. The right syntax to access multidimensional arrays is array[a][b] and not array[a, b].Assuming your array contains the right answer for question 0 at index 2, you can access that like this
cat4Answers[0][2]
.