Results 1 to 9 of 9
  1.    #1  
    Run into a problem that I am having a hard time to work out just what the problem is.

    I have a scene that is called from another scene with some arguments. The args are built up as follows and the scene called:

    Code:
    this.scoreCard = {
            players: [{
                name: "",
                score: "",
                putts: "",
                topar: "",
                holes: [{
                    score: "",
                    putts: ""
                }]
            }]
        };
    
    args = {
            courseID: this.selectorsModel.currentCourse,
            teeID: this.selectorsModel.currentTees,
            players: this.players,
            numPlayers: this.numPlayers,
            courseName: this.courseName,
            holes: this.holes,
            currHoleNum: this.holes[0].holenum,
            scoreCard: this.scoreCard
        };
    
    this.controller.stageController.pushScene("scorecard", args);
    When the scorecard scene is called everything is fine. Within the scorecard scene it will call itself using swapScene, passing the same args, and this is where the problem occurs since the app crashes.

    When I call swapScene I do the following:
    Code:
    this.args = {
            courseID: this.courseID,
            teeID: this.teeID,
            players: this.players,
            numPlayers: this.numPlayers,
            courseName: this.courseName,
            holes: this.holes,
            currHoleNum: this.currHoleNum,
            scoreCard: this.scoreCard
        };
    
    Mojo.Controller.stageController.swapScene("scorecard", this.args);
    I think the problem is related to the scoreCard class, as I'm pretty sure that the swapScene was working fine until I added this extra arg into the mix.

    Am I doing something wrong ? I don't get it because I am calling the scene with the exact same arguments, just that one is doing a pushScene and the other a swapScene.

    Any help would be much appreciated as I'm banging my head against a wall here.
  2.    #2  
    This is so bizarre. I don't understand why the arguments get passed perfectly when doing a pushScene, but crashes the application when using swapScene. If I take off the scoreCard class it works fine !

    Obviously I am doing something wrong.
  3.    #3  
    Ok, I think this issue is related more to the class that I have defined. Perhaps I have not defined it correctly. I am trying to populate the class with some default values and it's not working.

    Code:
    var scoreCard = {
    		players: [{
    			name: "",
    			score: "",
    			putts: "",
    			topar: "",
    			holes: [{
    				score: "",
    				putts: ""
    			}]
    		}]
    	};
    	
    	for (var i=0; i < this.players.length; i++){
    		scoreCard.players[i].name = this.players[i].name;
    		scoreCard.players[i].score = 0;
    		scoreCard.players[i].putts = 0;
    		scoreCard.players[i].holes = 0;
    		for (var j=0; j < this.holes.length; j++){
    			scoreCard.players[i].holes[j].score = -1;
    			scoreCard.players[i].holes[j].putts = -1;
    			this.controller.get('info_area').update('i=' + i + ', j=' + j);
    		}
    	}
    The lines:
    scoreCard.players[i].holes[j].score = -1;
    scoreCard.players[i].holes[j].putts = -1;

    are failing and I am not sure why that is.
  4. #4  
    Interesting - that looks like it should work. Have you tried peppering it with Mojo.Log.info() statements? I find that's a good way (well, the only way) to see exactly what line is causing a problem...
  5.    #5  
    If I put the this.controller.get command just inside the second loop it prints out the value of i and j. If however, I move it after either of the 2 subsequent commands the message never gets displayed.

    So, the following 2 lines are the ones that are failing:

    scoreCard.players[i].holes[j].score = -1;
    scoreCard.players[i].holes[j].putts = -1;
  6.    #6  
    Is there something wrong with the way that I am initially creating this object ?

    Code:
    	var scoreCard = {
    		players: [{
    			name: "",
    			score: "",
    			putts: "",
    			topar: "",
    			holes: [{
    				score: "",
    				putts: ""
    			}]
    		}]
    	};
    I'm just not getting why I can't populate this object with default values.
  7.    #7  
    Sorry to be a pain. Anybody on this ? It's driving me crazy and I really need to get this resolved.

    TIA.
  8. #8  
    That looks pretty correct to me.

    A few crazy ideas:
    - Is it possible there's some problem with using the variable name "score" twice? Try changing the name of one of them.
    - I swear once upon a time I had some problem with declaring an object that made me have to quote all the property names (i.e. "players": instead of players:, etc.). Maybe try that?
    - Try breaking up the declaration by declaring holes to be an empty array, and then on the next line add an element like you did there.

    This is a tough one...let me know how it goes!
  9. #9  
    Wait - I see it!

    You're setting

    scoreCard.players[i].holes = 0;

    and then treating holes as an array. Instead, set it to [] or something.

Posting Permissions