Results 1 to 2 of 2
  1. adma84's Avatar
    Posts
    285 Posts
    Global Posts
    323 Global Posts
       #1  
    I have an issue, where I can not stop listening to orientation events once I hit the one I care about..

    So to start listening, I use

    Code:
    this.controller.listen(document, 'orientationchange', this.handleOrientation.bindAsEventListener(this));
    THen I drop into a bit of code that does something like:

    Code:
    MainAssistant.prototype.handleOrientation = function(event){
    
        Mojo.Log.info("<===========Entered handleOrientation")
        if (event.position == 4 || event.position == 5) {
            this.controller.stopListening(document, "orientationchange", this.handleOrientation.bindAsEventListener(this))
            
            Mojo.Controller.stageController.swapScene({
                'name': 'car-summary'
            }, this.fillUpSummary, this.mileageTrack.reverse());
        }
        Mojo.Log.info("<===========Exited handleOrientation")
        
        
    };
    For some reason, it keeps swappping scenes over and over, because, Im pretty sure, that stopListening command is not working :-( any ideas? Thanks!
    My Programs: TipIt(TipCalc), FillUps
  2. mosdl's Avatar
    Posts
    781 Posts
    Global Posts
    787 Global Posts
    #2  
    The reason this isn't working is because you are not referencing the same event listener.

    What you need to do is this:

    Code:
    this.hoHandle = his.handleOrientation.bindAsEventListener(this);
    this.controller.listen(document, 'orientationchange', this.hoHandle);
    and then:

    Code:
     this.controller.stopListening(document, "orientationchange", this.hoHandle)
    Apps: MyQ for Netflix (Phone/TouchPad), Giantbomb (Phone), Excavate (Reddit/Digg clients for TouchPad)

Posting Permissions