2012-05-22 61 views
0

嗨我对actionscript 3很陌生,我想对类的使用做一些说明。我正在尝试使用http://sibirjak.com的AS3Commons UI项目。但我不确定如何使用他们的一些类。我已经在我的关键帧的一张经过格式化的方法是:Actionscript3关于类的用法的说明?

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()和不确定为什么我收到错误,能有人为我提供一些见解? http://sibirjak.com/osflash/blog/tutorial-creating-an-alert-box-with-the-as3commons-popupmanager/

回答

0

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

这就是说,假设你有AlertBoxAlertTutorialStep1类,它们的依赖,相对于它的正确的目录,我想如果你的文档类你的根都设置为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 
+0

谢谢,它看起来像你是正确的,感谢清理这个了,我有很多的声明和导入类的小东西,我需要一些帮助。它看起来像当我做了所有这些修复时,代码中有一个类名为IIterable的类中存在错误,我不想深入代码并可能修复错误。非常感谢,我想我会尝试为警报框创建我自己的课程。 –