0

I am very FRESHLY new to packages so forgive my simple question. How do I initialize the docTwo class and constructor function? I figured out how to call a static function from the main class but not to init another class. Thanks

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!");
    }

}

 }

1 Answer 1

2

Try to change your myDocClass like this:

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();

    ...
    ...

Note , they're both placed in the same package.

Sign up to request clarification or add additional context in comments.

11 Comments

That was it. Awesome. Thanks so much. It's all a bit mind bending sometimes but I am sure with time I will get it.
so myDocTwo = new docTwo(); is what calls it? and you need to declare the class at the top? Is that what you did?
@PapaDeBeau i defined myDocTwo as variable with docTwo , and instantiated it only in myDocClass constructor
I removed the import docTwo and it still worked. Why is that?
@PapaDeBeau import com.*; and in the class in this package you need write package com and not just package
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.