Posts Tagged “air”

I've updated the debugger used in SomaCore. You can know click on everything to parse the objects and I've added a FPS + Memory meter. I'll continue to improve the debugger with my needs, next step might be a Garbage Collection monitor.

Click here to see the debugger in action.

Tips: if you close the debugger, type "debug" to get it back.

Here is a little bit of code in case you want to want to use the debugger without using the SomaCore Framework.

Actionscript:
  1. package {
  2.    
  3.     import flash.display.Sprite;
  4.     import com.soma.core.Soma;
  5.     import com.soma.core.interfaces.ISoma;
  6.     import com.soma.debugger.SomaDebugger;
  7.     import com.soma.debugger.vo.SomaDebuggerVO;
  8.     import com.soma.debugger.events.SomaDebuggerEvent;
  9.    
  10.     public class Main extends Sprite {
  11.        
  12.         function Main() {
  13.             // create soma application
  14.             var app:ISoma = new Soma(stage);
  15.             // create debugger options
  16.             var vo:SomaDebuggerVO = new SomaDebuggerVO(app, SomaDebugger.NAME_DEFAULT, [], true, false);
  17.             // create debugger
  18.             var debugger:SomaDebugger = app.createPlugin(SomaDebugger, vo) as SomaDebugger;
  19.             // use debugger
  20.             debug("Hello Debugger");
  21.             debug(this);
  22.             debug(app);
  23.         }
  24.        
  25.         private function debug(obj:Object):void {
  26.             // use app.dispatchEvent() from a class that is not in the display list
  27.             dispatchEvent(new SomaDebuggerEvent(SomaDebuggerEvent.PRINT, obj));
  28.             // events available:
  29.             // SomaDebuggerEvent.SHOW_DEBUGGER;
  30.             // SomaDebuggerEvent.CLEAR;
  31.             // SomaDebuggerEvent.PRINT;
  32.             // SomaDebuggerEvent.HIDE_DEBUGGER;
  33.             // SomaDebuggerEvent.MOVE_TO_TOP;
  34.         }
  35.        
  36.     }
  37.    
  38. }

Vote in HexoSearch

Comments No Comments »

I had to get an AIR application without the OS window, let's say windowless or chromeless.

I needed to be able, with my own graphics, to minimize, restore, maximize, close, close in the system tray or dock, fullscreen and resize.

You can find several tutorials on Internet (with which I got inspired) but I put all these functionalities in one small example as it is convenient.

You need to set 2 parameters out of the code, in the XML description file:

Actionscript:
  1. <systemChrome>none</systemChrome>
  2. <transparent>true</transparent>

I won’t explain the code, I guess it is easy enough to find out. You can comment if something is not clear for you.

Here is the code of the main mxml file:

Actionscript:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" showFlexChrome="false" creationComplete="init()">
  3.  
  4. <mx:Script>
  5. <![CDATA[
  6.  
  7. [Embed(source="assets/iconDock.png")]
  8. [Bindable]
  9. public var IconDock:Class;
  10.  
  11. private function init():void {
  12.     registerMovementHandler();
  13.     setDock();
  14. }
  15.  
  16. public function registerMovementHandler():void {
  17.     appCanvas.addEventListener(MouseEvent.MOUSE_DOWN, mouseDrag);
  18.     btResizeBottomRight.addEventListener(MouseEvent.MOUSE_DOWN, resizeWindow);
  19.     btResizeBottomLeft.addEventListener(MouseEvent.MOUSE_DOWN, resizeWindow);
  20.     btResizeTopRight.addEventListener(MouseEvent.MOUSE_DOWN, resizeWindow);
  21.     btResizeTopLeft.addEventListener(MouseEvent.MOUSE_DOWN, resizeWindow);
  22. }
  23.  
  24. public function mouseDrag(e:MouseEvent):void {
  25.     if (e.target == e.currentTarget) stage.nativeWindow.startMove();
  26. }
  27.  
  28. public function resizeWindow(e:MouseEvent = null):void {
  29.     if (e.target == e.currentTarget) {
  30.         var corner:String;
  31.         switch(e.currentTarget){
  32.             case btResizeBottomRight:
  33.                 corner = NativeWindowResize.BOTTOM_RIGHT;
  34.                 break;
  35.             case btResizeBottomLeft:
  36.                 corner = NativeWindowResize.BOTTOM_LEFT;
  37.                 break;
  38.             case btResizeTopRight:
  39.                 corner = NativeWindowResize.TOP_RIGHT;
  40.                 break;
  41.             case btResizeTopLeft:
  42.                 corner = NativeWindowResize.TOP_LEFT;
  43.                 break;
  44.         }
  45.         stage.nativeWindow.startResize(corner);
  46.     }
  47. }
  48.  
  49. public function setDock():void {
  50.     if (NativeApplication.supportsSystemTrayIcon){
  51.         dockProperties();
  52.         SystemTrayIcon(NativeApplication.nativeApplication.icon).menu = dockMenu();
  53.     }
  54. }
  55.  
  56. private function dockProperties():void{
  57.     SystemTrayIcon(NativeApplication.nativeApplication.icon).tooltip = "Soundstep | chromeless window";
  58.     SystemTrayIcon(NativeApplication.nativeApplication.icon).addEventListener(MouseEvent.CLICK, undock);
  59. }
  60.  
  61. private function dockMenu():NativeMenu {
  62.     var menu:NativeMenu = new NativeMenu();
  63.     var open:NativeMenuItem = new NativeMenuItem("Open");
  64.     var close:NativeMenuItem = new NativeMenuItem("Close");
  65.     open.addEventListener(Event.SELECT, undock);
  66.     close.addEventListener(Event.SELECT, closeWindow);
  67.     menu.addItem(open);
  68.     menu.addItem(new NativeMenuItem("",true));
  69.     menu.addItem(close);
  70.     return menu;
  71. }
  72.  
  73. public function dock():void {
  74.     stage.nativeWindow.visible = false;
  75.     NativeApplication.nativeApplication.icon.bitmaps = [new IconDock() as Bitmap];
  76. }
  77.  
  78. public function undock(evt:Event):void {
  79.     stage.nativeWindow.visible = true;
  80.     stage.nativeWindow.orderToFront();
  81.     NativeApplication.nativeApplication.icon.bitmaps = [];
  82. }
  83.  
  84. public function closeWindow(e:Event = null):void {
  85.     stage.nativeWindow.close();
  86. }
  87.  
  88. public function setFullscreen():void {
  89.     var state:String = (stage.displayState == StageDisplayState.FULL_SCREEN) ? StageDisplayState.NORMAL : StageDisplayState.FULL_SCREEN;
  90.     stage.displayState = state;
  91. }
  92.  
  93. ]]>
  94. </mx:Script>
  95.  
  96. <mx:Canvas right="0" left="0" top="0" bottom="0" backgroundColor="#CF3232" id="appCanvas">
  97.  
  98.     <mx:Label buttonMode="true" mouseChildren="false" text="Min" top="10" color="#000000" id="btMin" click="minimize()" horizontalCenter="58"/>
  99.     <mx:Label buttonMode="true" mouseChildren="false" text="Max" top="10" color="#000000"  id="btMax" click="maximize()" horizontalCenter="-45"/>
  100.     <mx:Label buttonMode="true" mouseChildren="false" text="Close" top="10" color="#000000" id="btClose" click="closeWindow()" horizontalCenter="96"/>
  101.     <mx:Label buttonMode="true" mouseChildren="false" text="Restore" color="#000000" id="btRestore" click="restore()" top="10" horizontalCenter="-91"/>
  102.     <mx:Label buttonMode="true" mouseChildren="false" y="10" text="Tray/Dock" color="#000000" id="btSys" click="dock()" horizontalCenter="8"/>
  103.     <mx:Label buttonMode="true" mouseChildren="false" text="Fullscreen" color="#000000" horizontalCenter="0" bottom="10" id="btFullscreen" click="setFullscreen()"/>
  104.    
  105.     <mx:Canvas width="20" height="20" backgroundColor="#7B0707" borderStyle="none" borderColor="#FFFFFF" id="btResizeBottomRight" themeColor="#494949" right="0" bottom="0" />
  106.    
  107.     <mx:Canvas width="20" height="20" backgroundColor="#7B0707" borderStyle="none" borderColor="#FFFFFF" id="btResizeTopLeft" themeColor="#494949"  left="0" top="0" />
  108.    
  109.     <mx:Canvas width="20" height="20" backgroundColor="#7B0707" borderStyle="none" borderColor="#FFFFFF" id="btResizeBottomLeft" themeColor="#494949" bottom="0" left="0" />
  110.  
  111.     <mx:Canvas width="20" height="20" backgroundColor="#7B0707" borderStyle="none" borderColor="#FFFFFF" id="btResizeTopRight" themeColor="#494949" right="0" top="0" />
  112.  
  113. </mx:Canvas>
  114.    
  115. </mx:WindowedApplication>

You can download the source or install the AIR application:

In order to view this page
You must enable Javascript
And download the Flash Player
get flash player


Vote in HexoSearch

Comments 5 Comments »