0

我对包裹非常陌生,所以请原谅我的简单问题。如何初始化 docTwo 类和构造函数?我想出了如何从主类调用静态函数而不是初始化另一个类。谢谢

myDocClass.as

package  {

import flash.display.MovieClip;
import docTwo;



public class myDocClass extends MovieClip 
{

    var Hello:String = "Hi there";

    public function myDocClass () 
        {
        trace("And all the people said...  " + Hello);
        docTwo.docTwo(); /// Does NOT WORK. How do I call this or init class? 
        thisWorks();
                    // Below call Works
        docTwo.docTwoFunction();
        }

        public function thisWorks()
        {
            trace("Cool Beans! This one worked");
        }

}/// end of Class


}

docTwo.as

package  {
import flash.display.MovieClip;

public class docTwo{

    public function docTwo() 
    {
        trace("Trying to get this to work!");
        docTwoFunction(); // How do I call this from here?
    }

    static public function docTwoFunction()
    {
        trace("I am inside docTwo. Woo hoo!");
    }

}

 }
4

1 回答 1

2

试着改变你的myDocClass样子:

public class myDocClass extends MovieClip 
{

    var Hello:String = "Hi there";
    var myDocTwo:docTwo ;

     public function myDocClass () 
        {
           trace("And all the people said...  " + Hello);
           myDocTwo = new docTwo();

    ...
    ...

请注意,它们都放在同一个包中。

于 2013-06-07T20:02:30.157 回答