Skip to content

Instantly share code, notes, and snippets.

@dhollaway
Last active August 2, 2017 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhollaway/8035c406482e5293af2be5e7f856fd20 to your computer and use it in GitHub Desktop.
Save dhollaway/8035c406482e5293af2be5e7f856fd20 to your computer and use it in GitHub Desktop.
Shared Object Problem
//******************************* In the Settings class
private function loadButtons():void
{
//Background sound
if(StatsMain.g_status_bgSoundON == true)
{
_BackgroudSoundON.visible = true;
_BackgroudSoundOFF.visible = false;
}
else
{
_BackgroudSoundON.visible = false;
_BackgroudSoundOFF.visible = true;
//GameSoundManager.bgSounds_Group.mute = true;//sound is on.
}
}
//Settings click. When the sound is turned off.
private function turnOFF_BackgroundMusic():void
{
//OFF button is now showing
//GameSoundManager.bgSounds_Group.mute = true;
_BackgroudSoundOFF.visible = true;
_BackgroudSoundON.visible = false;
StatsMain.g_status_bgSoundON = false;
//Sets the status of the sound
//StatsMain.gameSharedObject.data.bgSoundisOFF = true;
//StatsMain.gameSharedObject.data.bgSoundisON = false;
//Save the sound setting
StatsMain.saveSharedObject();
trace("SceneSettings>turnOFF_BackgroundMusic(): The background sound is: " +StatsMain.g_status_bgSoundON);
}
//******************************* In the StatsMain class
public static var g_status_bgSoundON:Boolean;
if (!gameSharedObject.data.bgSoundisON)
{
gameSharedObject.data.bgSoundisON = true;
//GameSoundManager.bgSounds_Group.mute = false;
}
//Sound
g_status_bgSoundON = gameSharedObject.data.bgSoundisON;
public static function saveSharedObject():void
{
gameSharedObject.data.totalGlobalScore = g_TotalScore;
gameSharedObject.data.totalProblemsCorrect = g_TotalProblemsCorrect;
gameSharedObject.data.totalProblems = g_TotalProblems;
gameSharedObject.data.bonusPoints = g_BonusPoints;
gameSharedObject.data.bgSoundisON = g_status_bgSoundON;
gameSharedObject.data.fxSoundisON = g_status_fxSoundON;
gameSharedObject.flush ();
trace("StatsMain: All objects have been flushed!");
trace("StatsMain: The variable for bg sound is: " +g_status_bgSoundON);
trace("StatsMain: The Shared Object for bg sound is: " +gameSharedObject.data.bgSoundisON);
/*trace("STATS MAIN [START]********************************************************");
trace("The flush statement has excuted!");
trace("Status of the bgSoundisON: " +gameSharedObject.data.bgSoundisON);
trace("-----------------------------------------------------------");
trace("STATS MAIN [END]**********************************************************");*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment