【问题标题】:Why the actionscript 3.0 snippet below failed to import Button and TextInput?为什么下面的 actionscript 3.0 片段无法导入 Button 和 TextInput?
【发布时间】:2023-03-27 16:36:01
【问题描述】:
package
{
    import fl.controls.Button;
    import fl.controls.TextInput;
    public class MinRecord extends Sprite
    {
          private var recordBtn:Button;
          private var stopBtn:Button;
          private var textInput:TextInput;
...

当我运行它时报告:

Type was not found or was not a compile-time constant: Button.
Type was not found or was not a compile-time constant: TextInput.

有人能指出这里有什么问题吗?

【问题讨论】:

  • 你想从 Flex builder 编译这个吗?
  • @Amarghosh ,我正在从 Flash CS5 编译它。
  • 你能编译其他项目吗?你能导入flash.net.URLRequest吗?如果没有任何效果,可能是您的类路径设置错误。我不确定如何在 CS5 上修复它
  • 我不知道这意味着什么以及如何处理它:a definition for the document class could not be found in the classpath,so one will be automatically generated in the swf file upon export

标签: actionscript-3


【解决方案1】:

您是否将TextInputButton 组件添加到库中?

  • 从 组件面板到库 面板。
  • 从 组件面板到库 面板。

确保在您的图书馆中有。

这些应该是 Flash CS5 的 GUI 组件。

编辑:我看到您还没有设置文档类,或者可能没有正确设置

文档类是当您的 FLA 作为 SWF 发布时与它相关联的顶级类。当您单击“测试电影”或“发布”时,该类的实例将生成到 swf 中最高级别的对象,从而允许访问属性和方法。

您想取消选择主舞台上的所有对象并单击空白区域。然后您将看到带有文档属性(宽度、帧率等)的属性窗口。您将寻找 Document 类框并插入您的 actionscript 文件的名称。假设您在 Main.as 中有所有主要代码,您想插入 Main(没有 .as 扩展名)

【讨论】:

  • 将 TextInput 组件从“组件”面板拖到“库”面板。对 Button 执行相同的操作。
  • 正如我所说,这些组件是 Flash CS5 的一部分,而不是 ActionScript 3 主库的一部分,因此您需要将其添加到库中才能访问它。它主要用于 Flash IDE。
猜你喜欢
  • 2011-08-31
  • 1970-01-01
  • 2011-07-03
  • 2012-04-14
  • 2016-12-23
  • 2022-08-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多