Full Screen Applications?

Discussion in 'Flash Development' started by modular, Apr 28, 2012.

  1. modular

    modular

    New Member

    Joined:
    Nov 14, 2011
    Messages:
    12
    Hello, is there any way to make a Flash application (exported from Unity) show in full screen?
  2. tripknotix

    tripknotix

    Member

    Joined:
    Apr 21, 2011
    Messages:
    535
    they are working on enabling full screen, currently, you would have to create a flash swf shell for full screen, and the mouse lock does not yet play nicely with unity swf's, they are working on that too, hopefully the next unity update will have both
  3. RalphH

    RalphH

    Unity Technologies

    Joined:
    Dec 22, 2011
    Messages:
    546
    hi. The next update won't have either yet. I've looked at both things, as they are codependent; we'll have this in sooner rather then later after the next build; however due to some disparity on how unity handles gui and how flash's security sandbox regarding enabling fullscreen works, this will need some workarounds for that on our end.

    In the mean time, having fullscreen can be done in the next build with a hack-ish workaround, which will give you access to the stage from nested actionscript. From there you could capture events from the stage and invoke fullscreen from those mouse events. When it's out I will show paste the workaround, however, it's not integrated or elegant at all. We are working hard on improving the flash build, but it's still in preview and not at release level yet.
  4. tripknotix

    tripknotix

    Member

    Joined:
    Apr 21, 2011
    Messages:
    535
    well i can paste the full screen interactive work around, the issue is, i did not bother writing the event from sending flash's movementX and movementY over to the Unity, because i thought the next build would have support for these. perhaps you can persuade the UT team to just add support for those 2 variables, but not actually use them. that would allow any hackish workaround to perform better rather than having to send constant movement variables from flash to unity when the mouse moves.
  5. autonomous411

    autonomous411

    New Member

    Joined:
    May 22, 2012
    Messages:
    6
    Hi Ralph, please do post the example on how to get access to the stage. I'm in need of this!
  6. catburton

    catburton

    New Member

    Joined:
    Mar 29, 2011
    Messages:
    43
  7. cannon

    cannon

    Member

    Joined:
    Jun 5, 2009
    Messages:
    704
    Nice! Thanks.
  8. ryamldess

    ryamldess

    New Member

    Joined:
    Jun 18, 2012
    Messages:
    3
    Any update on this? In a click handler I'm doing:

    ActionScript.Import("com.unity.UnityNative");
    ActionScript.Statement("UnityNative.stage.displayState = 'fullScreen'");
    ActionScript.Statement("trace(UnityNative.stage.displayState)");

    but I'm getting:

    SecurityError: Error #2152: Full screen mode is not allowed.
  9. RalphH

    RalphH

    Unity Technologies

    Joined:
    Dec 22, 2011
    Messages:
    546
    Normally, that's a flash error indicating that you don't have the allowFullScreenFlag set in your html. However, I've heard of people having issues with this on Flash 11.3 (in general, not just unity-flash). What version are you trying to run this on? Does your html have this flag ?
  10. ryamldess

    ryamldess

    New Member

    Joined:
    Jun 18, 2012
    Messages:
    3
    allowScriptAccess and allowFullScreen are both true (the wrapper is the one that Unity generates from the Flash build, which defaults them to true). The version I'm targeting is 11.2; my Flash player version is 11.2.202.235. From what I understand the full screen requesting code has to exist directly within the mouse or key handler in the ActionScript layer; looking at the generated code it seems as if this is not the case?
  11. RalphH

    RalphH

    Unity Technologies

    Joined:
    Dec 22, 2011
    Messages:
    546
    @ryamldess; yes indeed, you'll need to invoke the fullscreen using the flash wrapper; you can for example detect a click on stage on there and see if the point falls within a rect. For now this is the only way to do this, we'll have it fixed in the release.
  12. AnnaParker

    AnnaParker

    New Member

    Joined:
    Jun 21, 2012
    Messages:
    3
    Please give the example
  13. catburton

    catburton

    New Member

    Joined:
    Mar 29, 2011
    Messages:
    43
    @Anna, you can modify the preloader example to do this.

    You'll need to make the following changes to the AS3 source:
    - the UnityLoaderParams supplied to the UnityContentLoader will need to have the first parameter (scaleToStage) set to true.
    - add an event listener (e.g. KeyboardEvent, MouseEvent) and when that occurs, set the stage's displayState to StageDisplayState.FULL_SCREEN
  14. McRain

    McRain

    Member

    Joined:
    Mar 26, 2009
    Messages:
    130
    I get a sample from the archive and add the necessary code to as3.
    Unfortunately full screen is not available.
    This solution works?
  15. agang0718

    agang0718

    New Member

    Joined:
    Nov 1, 2012
    Messages:
    1
    Code (csharp):
    1.  
    2. import com.unity.UnityNative;
    3. import flash.display.Sprite;
    4. import flash.display.Stage;
    5. import flash.display.StageDisplayState;
    6. import flash.events.MouseEvent;
    7.  
    8. var hitArea:Sprite = new Sprite();
    9. hitArea.graphics.beginFill(0, 0);
    10. hitArea.graphics.drawRect(0, 0, 960, 580);
    11. UnityNative.stage.addChild(hitArea);
    12.            
    13. hitArea.addEventListener(MouseEvent.CLICK,onClick);
    14. function onClick(evt:MouseEvent):void
    15. {
    16.     UnityNative.stage.displayState=StageDisplayState.FULL_SCREEN;
    17. }
    18.  
  16. TommiH

    TommiH

    Member

    Joined:
    Jan 14, 2008
    Messages:
    121
    Did Unity put fullscreen in yet?
  17. TommiH

    TommiH

    Member

    Joined:
    Jan 14, 2008
    Messages:
    121
    Hello.

    Could someone who got this working perhaps give an explanation suitable for Flash newbies on how to get this to work? I think it'd help a lot of people (including me).
  18. mtoivo

    mtoivo

    New Member

    Joined:
    Jul 30, 2012
    Messages:
    274
    I haven't played with this, but I'd say the solution agang0718 posted would be the easiest way to go. And I'd probably implement it inside loader-swf, that then loads the unity created swf. TommiH, have you played with that kind of stuff before? It gives you way better control of the Flash specific stuff, and also makes it easier to tweak the flash-functionality without the need to compile unity-content every time you do some minor changes in it.

    With that method, you could easily, more or less, just copy-paste the code agang0718 provided.

    Shouldn't be impossible to create a static class out of that code and use it straight in Unity that way. Using 'inline' AS in unity might be also possible, but could get messy, with the functions at least.
    Last edited: Nov 23, 2012
  19. TommiH

    TommiH

    Member

    Joined:
    Jan 14, 2008
    Messages:
    121
    Thanks. I managed to get it working with the ActionScript class. In case someone as clueless as me is reading this, here's the code:

    Code (csharp):
    1. using UnityEngine;
    2. using UnityEngine.Flash;
    3.  
    4. public class FullScreenSwitcher : MonoBehaviour {
    5.    
    6.     public void Start(){
    7.         ActionScript.Import("com.unity.UnityNative");
    8.         ActionScript.Import("flash.display.Sprite");
    9.         ActionScript.Import("flash.display.Stage");
    10.         ActionScript.Import("flash.display.StageDisplayState");
    11.         ActionScript.Import("flash.events.MouseEvent");
    12.         ActionScript.Statement("var hitArea:Sprite = new Sprite();" +
    13.                                "hitArea.graphics.beginFill(0, 0);" +
    14.                                "hitArea.graphics.drawRect(0, 0, 960, 580);" +
    15.                                "UnityNative.stage.addChild(hitArea);" +
    16.                                "hitArea.addEventListener(MouseEvent.CLICK,onClick);" +
    17.                                "function onClick(evt:MouseEvent):void" +
    18.                                "{" +
    19.                                "UnityNative.stage.displayState=StageDisplayState.FULL_SCREEN;" +
    20.                                "}");
    21.     }
    22. }
  20. huang

    huang

    Member

    Joined:
    Aug 16, 2012
    Messages:
    34
    i do it with some warning


    the full screen worked, but can't response the key event。


    thanks!
  21. RalphH

    RalphH

    Unity Technologies

    Joined:
    Dec 22, 2011
    Messages:
    546
    @huang; if you target Flash 11.3 and above you can use StageDisplayState.FULL_SCREEN_INTERACTIVE in stead of StageDisplayState.FULL_SCREEN, which then will send key information. This was a restriction on earlier versions of the Flash Player.
  22. huang

    huang

    Member

    Joined:
    Aug 16, 2012
    Messages:
    34
    thanks a lot, now it's fine!
    Last edited: Nov 26, 2012
  23. Ghisallo

    Ghisallo

    Member

    Joined:
    Sep 27, 2012
    Messages:
    10
    Last edited: Dec 14, 2012