0
votes

I am building an application in Adobe AIR for Mac in HTML/JavaScript.

What I want to do is when the application loads, make the application go into full-screen mode using the correct native full-screen found in OS X Lion and above.

This is NOT using the displayState that Flash/Flex uses

If the users decides to exit full screen mode they will see the app in a native window and can re-enter full screen mode using the icon you get in the top-right of a window.

I've found some information about an extension here: http://forums.adobe.com/thread/1209193

FREObject _EnableFullScreenMode(FREContext ctx, void* functionData, uint32_t argc, FREObject argv[])
     {
        //We should be okay to do this, even on 10.6, according to this post:
        //http://www.cocoabuilder.com/archive/cocoa/311124-implementing-full-screen-for-10-7-but-app-should-also-run-on-10-6.html
        //We can't use [NSApp mainWindow] - didn't appear to work
        //This seems to though:
        NSArray * allWindows = [NSApp windows];
        if (allWindows.count > 0)
        {
            NSWindow *mainWindow = [allWindows  objectAtIndex: 0];
            NSWindowCollectionBehavior behavior = [mainWindow collectionBehavior];
            behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
            [mainWindow setCollectionBehavior:behavior];
        }

        //TODO: Return a boolean instead depending on if we found the main window
        return NULL;
     }

That looks to do what I want! But after reading the Adobe AIR docs I can't get my head around where this code should live in my app directory and how I can call it on app load.

So in my index.html I have:

$(document).ready(function() {

// Make window full-screen
// CALL THE EXTENSION TO MAKE THE APPLICATION FULL_SCREEN

// Make window active
window.nativeWindow.activate();

// Make it visible
window.nativeWindow.visible = true;

});

The initialWindow is not visible by default using <visible>false</false> in the application descriptor XML file. And is made visible and active on the document ready as shown above.

The missing piece is loading in the extension and making the window go native full-screen.

To break this question up:

  1. Where does the extension code go? E.g. do I create an extension file and put it in any particular location in the app directory?
  2. How do I then load the extension into the application
  3. Finally how do I then do the full-screen on document ready
  4. What happens in OS X below Lion? How did full-screen work before it was introduced?

Hopefully I can get pointed in the right direction as the docs have totally baffled me and don't explain how the extension file is created (to me at least).

1
@Eric HTML and jQuery - Cameron
@Eric No I'm building a HTML/JavaScript app using the AIR API and then packaging it using the AIR SDK. Apps in AIR can be either Flash or HTML and I've gone for the HTML option for my application. - Cameron
My bad I didn't understand at all what you were doing - Eric
Did you reference the API using <script src="AIRAliases.js" /> ? - Eric
@Eric Yes but I'm asking how to implement the extension. - Cameron

1 Answers

-1
votes

if you want to use adobe native extensions (ANE), you have to create the extension first using xCode for OSX.

You can find here the details on how to do that in this 5 parts tutorial: Building a native extension for iOS and Android.

After that you have to package it in your application. Here you have some informations on how to do that on Flash Builder or Flash professional: Using native extensions for Adobe AIR. it's explained in the part 5 of the previous tutorial too. If you work with FDT here is a link on how to add the ANE: Add an ANE using FDT.

The native extensions have on one side the native code and on other side the AS3 code. When all is ok you just have to call the correct method of your native extension and it should be good :)

I hope this could help you.