【问题标题】:Calling function in other Class not working调用其他类中的函数不起作用
【发布时间】:2010-02-25 20:43:24
【问题描述】:

大家好,不知道这里发生了什么:(

基本上我有一个函数需要告诉其他 2 个类做某事。它适用于以下类之一:BigPlayButton,但由于某种原因不适用于 Background。

TabMenu.as 类函数

注意:下面的函数将在我的 BigPlayButton 类中调用 hitPlayCircle 函数,但我收到背景 switchTitle 函数的未定义属性错误。

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



我已经导入了这两个类,所以不确定发生了什么:( 我确实正确设置了我的静态 var 实例变量。

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

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

我在两个课程中都有instance = this;...

我试图从 TabMenu 类调用的背景类中的函数:

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

错误消息(我似乎总是收到此错误)

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

【问题讨论】:

    标签: flash actionscript-3 class function instance-variables


    【解决方案1】:

    我猜Background.instance 在调用此函数时并未实例化。

    尝试追踪Background.instance的值。

    【讨论】:

    • 是的,我之前把它弄坏了,呵呵:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多