This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a super ghetto way of getting the path to a function | |
// It will only work in Flash Player Debugger and ADL | |
// ex: com.destroytoday.pool::ObjectWaterpark/getObjectPool() | |
// updated: Jackson Dunstan pointed out the code works without throwing the error | |
public static function getFunctionPath():String | |
{ | |
return (new Error().getStackTrace().match(/at [^)]+\)/g)[1] as String).substr(3); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.destroytoday.example | |
{ | |
public class StaticClass | |
{ | |
{ trace('constructed'); } // <-- static constructor | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hotkeyManager:HotkeyManager = new HotkeyManager(stage); | |
// use-case with handlers | |
hotkeyManager.createHotkey("@").executed.add(lookupUserHotkeyHandler); | |
hotkeyManager.createHotkey("command+s").executed.add(saveHotkeyHandler); | |
// use-case with commands | |
signalCommandMap.mapSignal(hotkeyManager.createHotkey("@").executed, lookupUserCommand); | |
signalCommandMap.mapSignal(hotkeyManager.createHotkey("command+s").executed, saveCommand); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage = new NativeWindow(new NativeWindowInitOptions()).stage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// can be used to create a menubar without a ton of boilerplate | |
(fileItem = new NativeMenuItem("File")).submenu = new NativeMenu(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// At the moment, AIR only has activate() and bringToFront() for focusing windows, | |
// but it lacks any methods for unfocusing. Though unfocusing a window is a pretty | |
// rare action, it's necessary for some unit tests. Mine test a minimize menu item | |
// that is expected to be disabled if no windows are focused. I don't see the AIR | |
// team adding a deactivate() method, but I do see the possibility of setting | |
// NativeApplication.nativeApplication.activeWindow to null. Right now, it's read-only. | |
var window:NativeWindow = NativeApplication.nativeApplication.activeWindow; | |
window.visible = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NativeMenuItem(label:String = '', isSeparator:Boolean = false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected var shape:Shape = new Shape(); | |
public function invalidate():void | |
{ | |
shape.addEventListener(Event.ENTERFRAME, invalidateHandler); | |
} | |
protected function invalidateHandler(event:Event):void | |
{ | |
stage.removeEventListener(Event.ENTERFRAME, invalidateHandler); |