开发者

Calling function in other Class not working

开发者 https://www.devze.com 2022-12-21 02:23 出处:网络
Hey everyone, not sure what is going on here :( Basically I have a function that is needs to tell 2 other classes to do something. It works for one of the classes: BigPlayButton, but not Background f

Hey everyone, not sure what is going on here :(

Basically I have a function that is needs to tell 2 other classes to do something. It works for one of the classes: BigPlayButton, but not Background for some reason.

TabMenu.as Class function

Note: The function below WILL call the hitPlayCircle function in my BigPlayButton class, but I get an undefined property error for the Background switchTitle function.

private function thumbClick(e:MouseEvent = null):void
    {
        trace("YOU CLICKED THUMBNAIL: " + e.target.id);
        trace("PLAY THIS VIDEO: " + tabData[tabID].video[e.target.id].@flv);
        trace("THE VIDEO TITLE: " + tabData[tabID].video[e.target.id].@title);

        newTitle = tabData[tabID].video[e.target.id].@title;
        Background.instance.switchTitle(newTitle);

        BigPlayButton.instance.playState = false;
        BigPlayButton.instance.hitPlayCircle(); // Hide the big play button

        vdp.setflvSource(tabData[tabID].video[e.target.id].@flv);
        vdp.playNewVideo(tabData[tabID].video[e.target.id].@flv);
    }

I've imported both classes so not sure what's going on :( I did correctly set m开发者_StackOverflow中文版y static var instance variables.

public static var instance:Background; //<- in Background Class

public static var instance:BigPlayButton; // <- in BigPlayButton Class

And I have instance = this; in Both Classes as well...

The function inside my Background Class I'm trying to call from my TabMenu Class:

public function switchTitle(sentText):void
    {
        titleString = sentText;
        vTitle.text = titleString;
    }

Error Message (I always seem to get this error)

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at ui::TabMenu/thumbClick()


I would guess that Background.instance is not instantiated at the point this function is called.

Try tracing the value of Background.instance.

0

精彩评论

暂无评论...
验证码 换一张
取 消