Blackberry Playbook: user starts up the application by clicking a file

204 views Asked by At

I'm trying to do an unzip like application for the Blackberry Playbook, which means that the application mostly gets launched when the user clicks a file for which the app is registered.

I googled a bit around, and the closed what I found is this, but MobileApplication doesn't have invoke parameter.

<?xml version="1.0" encoding="utf-8"?>
<s:MobileApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                     xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.TestHome"
                     invoke="onAppInvoke(event)">
    <fx:Declarations>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            private function onAppInvoke(event:InvokeEvent):void {
                if (event.arguments.length>0) {
                    // ok app call with an arguments
                    var fileName:String=event.arguments[0];
                    trace("app open with : "+fileName);
                } else {
                    // app open normally
                    trace("normal launch");
                }
            }
        ]]>
    </fx:Script>
</s:MobileApplication>
1

There are 1 answers

0
catlan On BEST ANSWER

Found it:

<?xml version="1.0" encoding="utf-8"?>
<s:MobileApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                     xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.TestHome"
                     applicationComplete="myAppMain()">
    <fx:Declarations>

    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            private function myAppMain():void {
                NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onAppInvoke);
            }

            private function onAppInvoke(event:InvokeEvent):void {
                if (event.arguments.length>0) {
                    // ok app call with an arguments
                    var fileName:String=event.arguments[0];
                    trace("app open with : "+fileName);
                } else {
                    // app open normally
                    trace("normal launch");
                }
            }
        ]]>
    </fx:Script>
</s:MobileApplication>