AS3 错误 #1502
AS3 错误:错误 #1502:脚本的执行时间超过了默认的 15 秒超时时间。
有没有办法暂时抑制特定代码块上的这种情况?
我正在创建一个巨大的动态 3D 对象数组,1000x1000x1000,并且需要构建来实际完成初始化。
AS3
Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
Is there a way to temporarily suppress this on a specific block of code?
I am creating a HUGE dynamic 3d array of objects, 1000x1000x1000 and need the build to actually finish the initializing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你最好的选择是尝试重构你的代码。也许您可以利用本教程来解决您遇到的确切问题。
Your best bet would be to try and refactor your code. Perhaps you can make use of this tutorial which deals with the exact problem you are having.
http://www.senocular.com/flash/tutorials/asyncoperations/
增加超时是一种选择,但是我还建议考虑一种在多个帧上构建数组的方法,即将工作分成单独的作业。只要您每隔一段时间将控制权交还给 Flash Player,就不会出现此异常。
我不确定您的问题的具体情况,但是您需要找到一种并行化或简单地分段计算的方法。如果您的算法以一个主循环为中心,那么请考虑创建一个函数,该函数采用记录单次迭代的上下文所需的所有参数。然后,创建一个简单的控制循环来调用此函数并确定何时等待下一帧,何时不等待。利用 AS3 闭包也可以帮助解决这个问题。
Increasing the timeout is one option, however I would also suggest considering an approach that would build your arrays over multiple frames, that is splitting the work up into separate jobs. As long as you give control back to the Flash Player every once in a while, you will not get this exception.
I'm not certain of the specifics of your problem, however you will need to find a way to parallelize or just simply segment your calculations. If your algorithm centers around one major loop, then consider creating a function that takes all of the arguments necessary to record the context of a single iteration. Then, create a simple control loop that will call this function and determine when to wait until the next frame and when not to. Leveraging AS3 closures can also help with this.
在“发布设置”(Flash) 中查找脚本执行时间限制。如果您使用的是 Flex,可能是这个 可能有用:http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_14.html(检查默认脚本限制、最大递归深度、最大-执行时间)。哦!似乎显然没有办法让它在特定的代码段上以不同的方式表现(这是一个全局设置)。
Look for the script execution time limit in the "Publish Settings" (Flash). If you're using Flex, maybe this one can be useful: http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_14.html (check default-script-limits, max-recursion-depth, max-execution-time). Oh! It seems there's apparently no way to make it behave in a different way on a specific piece of code (it is a global setting).
我不同意增加超时选项。因为在这段时间里,您的应用程序只是挂起整个 Flash 播放器。通常用户认为它已关闭,并强制它退出。
看看这个:如何在flex-as3的循环中显示进程当前的progressBar值?
然后你甚至可以显示进度,这对你来说真的更有信心对于用户。
I do not approve the increse timeout option. Because for all this time your appllication is just hangs the whole Flash player. And normaly user thinks it is down, and forses it to quit.
check this one out: How to show the current progressBar value of process within a loop in flex-as3?
And then you can even show the progress which would be really more confident for you and for user.