Jump to content

Function in object keeps disappearing after being executed?


MySQL_Narb
Go to solution Solved by 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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.