Search code examples
actionscriptairblackberry-playbook

Option menu on Playbook view


How to make option menu on Playbook view? Is there standard APIs to do that, I am using Air SDK


Solution

  • I couldn't find the API at the time I was experimenting with AIR, but I found a work around.

    Basically I registered for touch events in QNXApplication and was manually showing and hiding my menu with the use of the Tweener.

    Suppose you have you menu as a view than you could do the following:

    // call back function when the main view is loaded
    protected function registerMenu( event:FlexEvent ):void
    {
        QNXApplication.qnxApplication.addEventListener( 
                                       QNXApplicationEvent.SWIPE_DOWN, 
                                       pullDownMenu );
        navigator.addElement(menu);
    }
    
    private function pullDownMenu( event:QNXApplicationEvent ):void
    {
    
        Tweener.addTween(menu, {y: 0, time: 0.5, transition: "linear"});                                   
        navigator.stage.addEventListener(MouseEvent.CLICK, onStageMouseClick);
        trace("menu down");
    }           
    
    private function onStageMouseClick( e:MouseEvent ):void
    {
        if (mouseY > menu.height)
        {
           Tweener.addTween(menu, {y: -menu.height, time: .3, transition: "linear"});                               
           trace("menu up");
        }
    }
    

    This is very simple example that I can remember (don't have the code anymore), but a bit of google-ing on this functions and objects might help you to implement the application menu without the API if it exits.

    If you find another way of doing it, please post it here for reference.