Oskar Pålsson
Oskar Pålsson

Reputation: 129

Calling AS3 fullscreen with javascript

I got two AS3 functions. One that toggles fullscreen and one that is called with javascript with ExternalInterface that only logs "Hello World".

Both works well in the browser, but if I try to call the fullscreen function with javascript the same way, i get an error like this:

Error calling method on NPObject!

I googled that problem but that only had something to do with same domain access, and sinced it worked with the other function, it has to be something else.

What am I doing wrong?

Upvotes: 1

Views: 2948

Answers (2)

Mrugesh
Mrugesh

Reputation: 471

Definitely you can initiate fullscreen for the Flash movie which is running in the Web-Browser. but you have to make full screen mode enabled in HTML Code...

Please read this topic:

The following restrictions apply to SWF files that play within an HTML page (not those using the stand-alone Flash Player or not running in the AIR runtime):

* To enable full-screen mode, add the allowFullScreen parameter to the object and embed tags in the HTML page that includes the SWF file, with allowFullScreen set to "true", as shown in the following example:

  <param name="allowFullScreen" value="true" />
            ...
      <embed src="example.swf" allowFullScreen="true" ... >

  An HTML page may also use a script to generate SWF-embedding tags. You need to alter the script so that it inserts the proper allowFullScreen settings. HTML pages generated by Flash Professional and Flash Builder use the AC_FL_RunContent() function to embed references to SWF files, and you need to add the allowFullScreen parameter settings, as in the following:

  AC_FL_RunContent( ... "allowFullScreen", "true", ... )

* Full-screen mode is initiated in response to a mouse click or key press by the user; the movie cannot change Stage.displayState without user input. Flash runtimes restrict keyboard input in full-screen mode. Acceptable keys include keyboard shortcuts that terminate full-screen mode and non-printing keys such as arrows, space, Shift, and Tab keys. Keyboard shortcuts that terminate full-screen mode are: Escape (Windows, Linux, and Mac), Control+W (Windows), Command+W (Mac), and Alt+F4.

  A Flash runtime dialog box appears over the movie when users enter full-screen mode to inform the users they are in full-screen mode and that they can press the Escape key to end full-screen mode.
* Starting with Flash Player 9.0.115.0, full-screen works the same in windowless mode as it does in window mode. If you set the Window Mode (wmode in the HTML) to Opaque Windowless (opaque) or Transparent Windowless (transparent), full-screen can be initiated, but the full-screen window will always be opaque.

Then after you have to make one function in the ActionScript 3.0 to change the Stage.displaystate making fullscreen.

To call actionscript 3.0 function from the JavaScript you can use the ExternalInterface API of ActionScript 3.0. Please refer the ExternalInterface class API description in Adobe Help.

Upvotes: -2

Rick van Mook
Rick van Mook

Reputation: 2065

The fullscreen mode can only be set by user input. So I'm affraid calling it from javascript is not allowed.

Full-screen mode is initiated in response to a mouse click or key press by the user; the movie cannot change Stage.displayState without user input. Flash runtimes restrict keyboard input in full-screen mode. Acceptable keys include keyboard shortcuts that terminate full-screen mode and non-printing keys such as arrows, space, Shift, and Tab keys. Keyboard shortcuts that terminate full-screen mode are: Escape (Windows, Linux, and Mac), Control+W (Windows), Command+W (Mac), and Alt+F4.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#displayState

Upvotes: 4

Related Questions