AS3: Cannot call a function in class

时间:2018-03-25 20:02:19

标签: function class oop actionscript-3 call

I'm pulling my hair out trying to figure out why this doesn't work. I'm trying to call a function from the document class that is found inside of an instance of a MovieClip.

In the document class I have:

import com.BudgetSettings;
showSettings();

function showSettings():void
{
    var settings:BudgetSettings = new BudgetSettings;
    addChild(settings);
    settings.addListeners();
}

Then in the BudgetSettings class I have:

package com {

    public class BudgetSettings extends MovieClip
    {
        public function BudgetSettings():void
        {
            //constructor code
        }

        public function addListeners():void
        {
            trace("got here");
        }
    }
}

This seems like a routine call to a function inside of a class instance, but it produces Error #1006: addListeners is not a function. I tried creating other functions as well, and the same error is produced.

It seems as if the class instance is created and placed on the stage just fine, but any methods inside of it cannot be called from the document class. I double checked, and the path to the class is correct.

Any help is welcome!

0 个答案:

没有答案