AS3 Quickie – Mouse Lock and Relative Mouse Coordinates

Another great feature in Flash Player 11.2 is the combination of the mouseLock boolean in flash.display.Stage along with the ability to read movementX and movementY from MouseEvent.MOUSE_MOVE. When used within Flash Player, we must be in fullscreen for mouse lock to be enabled and the relative mouse coordinates made available. The primary focus of this feature is to provide a better experience in gaming – particularly in 3D games within which the player is able to move and look around the entire environment. This can also be useful in full screen simulations and experimental pieces. Requires Flash Player 11.2 or

Continue reading »

AS3 Quickie – Monitor Throttle Events

One of the great new features introduced with Flash Player 11.2 is the ability to detect when the runtime throttles, pauses, or resumes normal activity through the flash.events.ThrottleEvent class. This is useful for saving state, or pulling back our activity when a throttle is detected. What does the throttle actually do? Well, if you have multiple tabs open in a web browser, and navigate from a tab with Flash content to another tab – the Flash content will enter a throttled state in which the frames per second is drastically slowed down so as not to take any unnecessary resources.

Continue reading »

AS3 Quickie – Removing the right-click menu from Flash content

One of the great new features introduced with Flash Player 11.2 is the ability to intercept the right-click from a user’s mouse. A simple MouseEvent listener can be added to the Stage or any object which extends flash.display.InteractiveObject. Not only does this have the effect of completely removing the right-click menu from Flash content, but we can also alternatively react to the right-click in any way we choose. Requires Flash Player 11.2 or above! To enable this, we must import the MouseEvent class into our project: import flash.events.MouseEvent; Next, let’s add a listener to the Stage itself, disabling the context

Continue reading »

AS3 Quickie: Check if a variable is Numeric

I’m still doing loads of ActionScript work in both my regular job and in side projects – so thought I might start posting some tiny, useful snippets of AS3 here as I encounter them. This is, I suppose, both for my own archive and for anyone out in the community that cares to pick up on these bits and pieces. So this quickie comes from a project where I actually have an AIR application running as a service on a Windows 2008 virtual machine. The application monitors a remote folder for uploads from a web application in order to process

Continue reading »

Creating Custom Context Menus in Flash

The assets for my 5 minute quick tip talk for the 2011 Adobe Education Leader Institute are located here. This is the completed example (Flash Professional CS5.5): [download AEL2011_FlashContextMenu] Here is an image preview: Here is the SWF: Flash Player 11.2 or greater is required! And here be the code bits! package { import flash.display.Sprite; import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; import flash.ui.ContextMenuBuiltInItems; import flash.net.URLRequest; import flash.net.navigateToURL; import flash.events.ContextMenuEvent; public class CustomMenu extends Sprite { private const MENUITEM_FVM:String = “©2011 Fractured Vision Media, LLC”; private const MENUITEM_JOSEPH:String = “Joseph Labrecque”; public function CustomMenu(){ buildMenu(); } private function buildMenu():void { var myMenu:ContextMenu =

Continue reading »

Quick Tip: Display Application Version in your AIR App.

Just a quick tip for those looking to somehow display the AIR application version from the descriptor file. I’ve found it very helpful in troubleshooting is users can say EXACTLY what version of the app they are running. AIR 2.5 and later: private function getAppVersion():String { var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor; var ns:Namespace = appXml.namespace(); var appVersion:String = appXml.ns::versionNumber[0]; return appVersion; } Older versions of AIR: private function getAppVersion():String { var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor; var ns:Namespace = appXml.namespace(); var appVersion:String = appXml.ns::version[0]; return appVersion; }

Continue reading »