Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing classes from classes

Status
Not open for further replies.

silverswim

Programmer
Oct 17, 2001
50
GB
Hi... I'm having some trouble with these bits of code... I got some help before from wangbar to sort it out when the var stored was in a class of its own. But trying to access it from another class isn't working...

class Ipa{
var c : Settings;
function Ipa() {
}
}

class Settings {
var currSubs:Boolean;
function Settings (s:Boolean) {
currSubs = s;
}
function getSubsOn ():Boolean {
return currSubs;
}
function setSubsOn (s:Boolean):Boolean {
currSubs = s;
return currSubs;
}
}

then at root level:
var dpp : Ipa = new Ipa();
dpp.c.setSubtitlesOn(false);

and level 3:
_global.subtitles = _level0.dpp.c.getSubtitlesOn();

if ( _global.subtitles == false){
_level3.speech._visible = false;
};


And nothing happens...subtitles still showing...
Thanks in advance for help.
silverswim



 
Don't know if you cut and pasted this on not but your method names don't match - 'function setSubsOn' but 'dpp.c.setSubtitlesOn(false)'

Every time you change the status of the subtitles with your approach above you're instantiating a new class which isn't the best way to work here if I understand correctly what you're trying to do and may be contributing to your problem.

Do you know about the 'singleton' design pattern? This would be a better approach and should solve your problem - there are many articles on the web that show you the approach and it's very simple to implement. What it does is give you a single instance of your class to work from that acts as a central repository for information like the state of your subtitles.
 
Thanks wangbar; I'll try going down that road...I did cut and paste it...thats why- was trying to keep different possible implementations separate...silly...Thanks again, silverswim.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top