Jump to content

Function in object keeps disappearing after being executed?


MySQL_Narb

Recommended Posts

Here is bossScenario:

 

 

var bossScenario = {
'active': false,
        'scenario_ID':0,
'boss': {}
};

 

Here is a list of scenarios:

 

 

var scenarios = {
        1 : {
'func' : function(bossDifficulty){
/*var me = bossScenario['boss'][1];
var vars = me['vars'];
                        
                        vars[rbSoldiers] = bossDifficulty*100000;
                        vars[reward] = bossDifficulty;*/
                        
                        alert('test');
                        //randBossBattle(vars);
},
'vars' : {
                    rbSoldiers : 0,
                    reward : 0
                }
}
}

 

In bossScenario, I will assign a scenario to the 'boss' property. And then I will run the below code:

 

 

bossScenario['boss'][sID]['func'](bossDifficulty);

 

The above code will successfully alert "test"; however, next time I go to run the function, I get this error in the console:

 

Uncaught TypeError: Object #<Object> has no method 'func'

 

It's as if the 'func' property and its function are being removed from the bossScenario function after it is ran. Why is this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.