如何在AS3中使用else if { var而不返回1083错误?
我在 AS3 中有一个 if/else if/else if/else if/else 语句。
它是一个从 xml 文件读取日期的日历。 if/else if/else 语句根据日期是否有事件以及是过去/现在还是将来来控制日期的外观。 MouseEvent 是一个显示事件信息的工具提示。
最后一部分是
else {
var thisday:String = "<b><font color=\"#666666\" size=\"9\"> <u><font size=\"12\"> -</font> " + yy + " <font size=\"12\">-</font> " + GlllStringUtil.checkDigits((mm + 1).toString()) + " <font size=\"12\">-</font> " + i.toString() + " <font size=\"12\">- </font></u></font></b> ";
myCLabel = new ICLabel();
myCLabel.date.htmlText = GlllStringUtil.checkDigits(i.toString());
myCLabel.date.background = false;
myCLabel.date.textColor = "0x666666";
myCLabel.date.autoSize = TextFieldAutoSize.CENTER;
myCLabel.date.selectable = false;
myCLabel.date.mouseEnabled = true;
myCLabel.y = 0;
myCLabel.x = 25 * (i - 1);
myCLabel.name = i.toString();
myCLabel.data = thisday;
myCLabel.addEventListener(MouseEvent.MOUSE_OVER, myCLabel_mouse_over);
myCLabel.addEventListener(MouseEvent.MOUSE_OUT, myCLabel_mouse_out);
calendarHolder.addChild(myCLabel);
}
如果我在语句中重复这一点,我会得到 1084,因为使用 else if { var...
我可以使用 else,但是如果我用 if/else 开始下一部分,而它执行了我需要的操作 -外观被最后一个 if/else 覆盖。
我试图这样做是因为对于未来日期的出现只有一个声明,这意味着如果有未来事件 - 它不会突出显示。
如何在内部使用 else if { var 重复它,而不返回 1084?
(任何帮助将不胜感激,因为我对 AS3 知之甚少。)
--
更新:
非常感谢您的回复。
该文件是 .as 文件,而且很长,所以我所做的就是上传它 这里 作为 .txt 文件。还有 2 个小 gif 图像来尝试演示我想要实现的目标。 (您会注意到(在图像中)工具提示出现在突出显示的日期上方,但未来日期不会突出显示,因此您实际上无法判断是否有事件,除非您将鼠标悬停在日期上。)
我希望没关系。
在发布之前,我确实检查过以确保没有错过右大括号,但我认为该错误超出了我的理解范围。
I have an if/else if/else if/else if/else statment in AS3.
It's a calendar that reads in dates from an xml file. The if/else if/else statements controls the look of a date according to whether it has an event, and whether it's past/present or future. The MouseEvent is a tooltip which shows the Event information.
The last section is
else {
var thisday:String = "<b><font color=\"#666666\" size=\"9\"> <u><font size=\"12\"> -</font> " + yy + " <font size=\"12\">-</font> " + GlllStringUtil.checkDigits((mm + 1).toString()) + " <font size=\"12\">-</font> " + i.toString() + " <font size=\"12\">- </font></u></font></b> ";
myCLabel = new ICLabel();
myCLabel.date.htmlText = GlllStringUtil.checkDigits(i.toString());
myCLabel.date.background = false;
myCLabel.date.textColor = "0x666666";
myCLabel.date.autoSize = TextFieldAutoSize.CENTER;
myCLabel.date.selectable = false;
myCLabel.date.mouseEnabled = true;
myCLabel.y = 0;
myCLabel.x = 25 * (i - 1);
myCLabel.name = i.toString();
myCLabel.data = thisday;
myCLabel.addEventListener(MouseEvent.MOUSE_OVER, myCLabel_mouse_over);
myCLabel.addEventListener(MouseEvent.MOUSE_OUT, myCLabel_mouse_out);
calendarHolder.addChild(myCLabel);
}
If I repeat this inside the statement I get a 1084 for using else if { var...
I can use else, but then if I start the next section with if/else and while it does what I need - the appearance is overriden by this last if/else.
I am trying to do this because there is only one statment for the appearance of future dates, which means that if there is a future event - it's not highlighted.
How can I repeat it inside using else if { var, without it returning 1084?
(Any assistance would be greatly appreciated as I have very little knowledge of AS3.)
--
Update:
Thank you so much for your reply.
The file is a .as and it's quite long so what I've done is upload it here
as a .txt file. There are also 2 small gif images to try and demonstrate what I'm trying to acheive. (You'll notice (in the image) the tool tip appears over a highlighted date, but otherwise Future Dates aren't highlighted therefore you can't actually tell if there is an event unless you mouse over a date.)
I hope that is okay.
I did check to make sure that I didn't miss the closing brace before I posted but I think the error is beyond my understanding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1084 是一个错误,表明语法错误。你错过了闭合大括号或类似的东西。如果您想获得更准确的答案,请发布完整的功能代码:)
1084 is an error indicating bad syntax. you've missed closing a brace or something along those lines. post the complete function code if you want to get a more precise answer :)
您似乎正在更改下载的库。我想我理解您的问题,但不幸的是,很难帮助您找到准确的解决方案。
这些块遵循以下模式:
这是
if
语句的工作方式。只能有一个else
并且它必须出现在最后。它处理所有if
和else if
条件均无法匹配时发生的情况。这有点像“最后手段”的行动。您在链接的代码的注释中说:“此块控制没有事件时日期的样子。”并且您想要添加一个在发生事件时进行处理的块。这意味着您想要添加一个新的
else if
。为此,您需要提供一个条件。该代码比我愿意投入的代码要复杂一些,以帮助您确定如何编写一个条件,当该日期有事件时,该条件的计算结果为 true。但是与我所显示的形式相匹配的语句应该可以工作并解决您的 1084 错误。
It looks like you are altering a library you downloaded. I think I understand your problem, unfortunately it will be difficult to help you with an exact solution.
The blocks follow this pattern:
This is the way
if
statements work. There can be only oneelse
and it has to come right at the end. It handles what happens when all of theif
andelse if
conditions fail to match. It is kind of like the "last resort" action.You say in the comments of the code you linked: "This block controls what the dates look like if there are NO Events." and you want to add a block that handles when there are events. That means you want to add a new
else if
. To do so you need to provide a condition.The code is a little more complicated than I am willing to invest to help you determine how to write a condition that evaluates to true for a particular date when there are events for that date. But a statement that matches the form I have shown should work and get around your 1084 error.