需要课程帮助
我是 ActionScript 3/ Flash CS4 的新手,我正在学习 ActionScript(OOP) 课程。我的文件夹中有两个文件 - Pro.fla(我的 Flash 项目)和 .as(Pro.as)。我在 Pro.as 中创建了类:
package{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Pro extends MovieClip
{
private var button:my_button=new my_button(); // is the button from the library (MovieClip), which has been linkage Base class: Pro and class: my_button
public function Pro()
{
button.x+=2050;
}
}
}
当我按 ctrl+enter 时,出现错误:错误:错误#1023:堆栈溢出, 有什么问题,有人可以帮我解决吗?先感谢您!
i am new in ActionScript 3/ Flash CS4, i am learning classes in ActionScript(OOP). I have in my folder two files - Pro.fla (my flash project) and .as (Pro.as). I created class in Pro.as:
package{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Pro extends MovieClip
{
private var button:my_button=new my_button(); // is the button from the library (MovieClip), which has been linkage Base class: Pro and class: my_button
public function Pro()
{
button.x+=2050;
}
}
}
when i ctrl+enter, i have a mistake: Error: Error #1023: Stack overflow,
What is the problem, can anyone help me with that? Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来你有一个递归问题。在您的评论中,您提到“my_button”有一个基类“Pro”。我猜测“Pro.as”是您的文档类,而不是按钮的基类。现在,因为 Pro 是按钮的基类,并且您在 Pro 中创建按钮,所以它创建了一个无限循环。
如果您还没有为按钮创建基类,您可能需要将其设置为“flash.display.Sprite”或“flash.display.MovieClip”以使其扩展 Sprite 或 MovieClip。
It looks like you have a recursion issue. In your comment, you mentioned that "my_button" has a base class of "Pro". I'm guessing "Pro.as" is your Document class and not the base class of your button. Right now, because Pro is the base class of the button, and you're creating the button within Pro, it's creating an endless loop.
If you haven't created a base class for the button, you probably want to set it to "flash.display.Sprite" or "flash.display.MovieClip" to have it extend either Sprite or MovieClip.
按钮的基类应该是
flash.display.SimpleButton
(或 MovieClip)The base class of the button should be
flash.display.SimpleButton
(or MovieClip)