Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oop Actionscript3类使用说明?_Oop_Class_Actionscript - Fatal编程技术网

Oop Actionscript3类使用说明?

Oop Actionscript3类使用说明?,oop,class,actionscript,Oop,Class,Actionscript,您好,我是ActionScript3的新手,我想了解一下类的使用。我正在尝试使用来自的AS3Commons UI项目。但我不确定如何使用他们的一些课程。我在其中一个关键帧中对其进行格式化的方式是: import com.AlertBox; // The location of the alertbox class import com.AlertTutorialStep1; // The location of the example AlertTutorialStep1 class var

您好,我是ActionScript3的新手,我想了解一下类的使用。我正在尝试使用来自的AS3Commons UI项目。但我不确定如何使用他们的一些课程。我在其中一个关键帧中对其进行格式化的方式是:

import com.AlertBox; // The location of the alertbox class
import com.AlertTutorialStep1; // The location of the example AlertTutorialStep1 class

var alertbox:AlertTutorialStep1 = new com.AlertTutorialStep1; // Creating an instance of the example class in the AlertTutorialStep1 doc

alertbox.AlertTutorialStep1(); // Trying to access the AlertTutorialStep1() function which is in the AlertTutorialStep1 class

但是我无法访问函数AlertTutorialStep1(),并且不确定为什么会出现错误,是否有人能提供一些见解

尽可能避免使用时间线。我认为,如果您知道自己在做什么,OOP和Flash时间线可以工作,但是stackoverflow充满了初学者在时间线和类方面的问题,这些问题往往很难调试。尝试使用一个主文档类来设置项目,该类实例化项目所需的所有其他类

也就是说,假设您在与其相关的正确目录中有
AlertBox
AlertTutorialStep1
类及其依赖项,我认为如果您将.fla的文档类设置为
AlertBoxTutorial1
类,您的代码将正常工作

再次假设所有包都已正确设置,您可以尝试用以下代码替换现有代码:

//import com.AlertBox; // Don't need to import this, AlertTutorialStep1 imports and uses it
import com.AlertTutorialStep1; // The location of the example AlertTutorialStep1 class

var alertbox:AlertTutorialStep1 = new AlertTutorialStep1(); // Don't need to fully qualify the class as it is already imported in the line above

this.addChild(alertbox); // Need to add the instance to the stage

//alertbox.AlertTutorialStep1(); // AlertTutorialStep1() is the constructor of the class and can't be invoked via an instance of it

谢谢,看起来你是对的,谢谢你澄清了这一点,我有很多关于类的声明和导入的小事情,我需要一些帮助。看起来,当我进行所有这些修复时,代码中出现了一个错误,在混乱的类中缺少一个名为IIterable的类,我不想深入研究代码并可能修复错误。非常感谢,我想我将尝试为警报框创建自己的类。