Thursday, February 25, 2010

Programmer - Calling function in other Class not working

Programmer Question

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 my 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 com.touchstorm.TEN.ui::TabMenu/thumbClick()


Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails