Results 1 to 10 of 10
  1.    #1  
    In my app I have two scenes, scene1 and scene2 say. When I push scene2 it appears over scene1.

    My problem is that when I swipe back, scene2 isn't being popped correctly. This means that when I press the button that pushes scene2 again, I end up with a duplicate (this means I have to swipe back twice to get back to scene one).

    Anyone have any idea why this could be happening? I've seen various threads related to similar issues but nothing that helps with this particular issue.
  2. #2  
    Do you have any code that might be failing inside of the scene-assistant's deactivate or cleanup function(s)? If javascript fails, it stops immediately. Put Mojo.Log.info messages at the top and the bottom of these two functions and make sure they show up. We can probably help more if we see some code.
  3.    #3  
    Both deactivate and cleanup are empty in my code.

    Here's a log of what's going on

    Code:
    [20100825-01:03:31.022785] info: About to activate scene  Front
    [20100825-01:03:31.024864] info: Beginning native scene transition: zoom-fade ,
    isPop= true
    [20100825-01:03:31.045316] info: Transition ended.
    [20100825-01:03:44.495961] info: About to activate scene  Load
    [20100825-01:03:44.504745] info: Transition ended.
    [20100825-01:03:45.345567] info: About to activate scene  Load
    [20100825-01:03:45.354494] info: Beginning native scene transition: zoom-fade ,
    isPop= true
    [20100825-01:03:45.383116] info: Transition ended.
    [20100825-01:03:46.672717] info: About to activate scene  Front
    [20100825-01:03:46.677514] info: Beginning native scene transition: zoom-fade ,
    isPop= true
    [20100825-01:03:46.700670] info: Transition ended.
    I tried adding logging comments but they threw errors (although the errors were in the log so that shows that the deactivate and cleanup methods are firing).
  4. #4  
    What code are using to push scene2?
  5. #5  
    You're putting your event listeners in your activate method aren't you? Put them in setup or put matching stopListening's in deactivate.
    danNielson.com - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.
  6.    #6  
    Thank you! For some reason having the event listeners in the activate method of the first scene was stopping the second scene from being popped.

    The only thing is, I don't understand why this affects it. Could you explain?
  7. #7  
    It's not stopping the scene from being popped, it's adding a new event listener every time you come back to your first scene. So initially, your button tap pushes the second scene one time, then when you come back your event listener gets bound again, so tapping your button pushes the second scene twice, then three times and so on.

    Always remember, activate gets called EVERY time you come back to your scene, not just the first time.
    danNielson.com - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.
  8.    #8  
    I know curiosity will kill me eventually but...

    say I wanted to keep a listener in my activate method which is passed this.myfunc.bind(this). What method do I pass to the stopListening function? this.myfunc or this.myfunc.bind(this) or the return value of the original listen call (if it returns a value at all)?

    Thanks again for all your help, my app is starting to form rather nicely.
  9. #9  
    a stopListening should look EXACTLY like its equivalent listen. And you should actually cache that this.myfunc.bind(this). Something like

    Code:
    blah
    MainAssistant.prototype = {
    ...blah...
      setup: function() {
        ...
        this.myButton = this.controller.get('myButton');
        this.bound_myFunc = this.myFunc.bind(this) //Or .bindAsEventListener(this) if you want to pass the event object to your handler.
        ...
      },
      activate: function() {
        ...
        this.controller.listen(this.myButton, Mojo.Event.tap, this.bound_myFunc);
        ...
      },
      ...
      deactivate: function(){
        ...
        this.controller.stopListening(this.myButton, Mojo.Event.tap, this.bound_myFunc);
        ...
      },
      ...
    }
    There are a lot of benefits to caching. In this particular case, the main one is that we ensure that the proper method gets bound and unbound to the proper widget, but caching can also improve performance by quite a lot in some cases.
    danNielson.com - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.
  10.    #10  
    Awesome, that makes much more sense. Thanks again for all the help!

Posting Permissions