Skip to content

Instantly share code, notes, and snippets.

View ThomasBurleson's full-sized avatar

Thomas Burleson ThomasBurleson

View GitHub Profile
@ThomasBurleson
ThomasBurleson / ItemRendererFactory.as
Created February 11, 2011 17:14
Flex - Refactoring of UIClassFactory
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2009 Farata Systems LLC
// All Rights Reserved.
//
// NOTICE: Farata Systems permits you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
@ThomasBurleson
ThomasBurleson / gist:890676
Created March 28, 2011 15:37
BabelFx - Use of XML to dynamically build MenuBar solution.
<?xml version="1.0" encoding="utf-8"?>
<mx:MenuBar
labelField="@label"
dataProvider="{ _menuDataProvider.menuitem }"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
<fx:Script>
<![CDATA[
public function set main(items:Array) :void { updateMenu( _menuDataProvider.menuitem, items); }
@ThomasBurleson
ThomasBurleson / gist:891377
Created March 28, 2011 21:58
Flex ItemRenderers - global data usages
<?xml version="1.0" encoding="utf-8"?>
<mx:DataGrid width="100%" height="100%"
xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
/**
* Array of localized, marker labels
*/
public var availableMarkers : Array = [ ];
@ThomasBurleson
ThomasBurleson / gist:925645
Created April 18, 2011 16:22
Swiz Metadata XML - Adapted for use in FB4 SWCs
<?xml version="1.0" encoding="utf-8"?>
<annotations version="1.0">
<metadata name="Dispatcher" description="Used to request injection of the root Swiz dispatcher (default) or the dispatcher for containing Swiz instance." >
<context name="variable" />
<context name="setter" />
<attribute name="scope" type="String" defaultValue="global" required="false" values="global,local," hint="string" />
</metadata>
@ThomasBurleson
ThomasBurleson / gist:941711
Created April 26, 2011 02:52
Supplant for AS3 [no more StringUtils.substitute]
package utils.string
{
/**
* Replaces all tokenized fields in target with field values from
* the fields datasource. With this routine, the mx StringUtils.substitute
* is no longer needed to achieve printf() functionality.
*
* Supplant is more powerful since it can resolve (on-demand) property chains
* when used as fields; e.g. user.name (as shown below).
*
@ThomasBurleson
ThomasBurleson / gist:972665
Created May 14, 2011 21:38
AS3 Functional Programming to Convert String list to BitFlags
"properties,size,displayList"
.split(",")
.map( function ( item:String, index:int, array:Array ):uint {
switch( StringUtil.trim( item ) )
{
case "displaylist": return InvalidationFlags.DISPLAY_LIST;
case "size" : return InvalidationFlags.SIZE;
case "properties" : return InvalidationFlags.PROPERTIES;
default : throw new Error( "Unsupported invalidation option specified." );
}
@ThomasBurleson
ThomasBurleson / Chaining with Async Events
Created May 25, 2011 13:17
Swiz EventChains with conditionals
[EventHandler(event="DeviceEvent.LOAD_SUMMARY",properties="device,filters,forceLoad")]
/**
* Here is an example of Parallel chaining. Developers should not that the workflow() method returns
* IAsynchronousOperation to allow workflow() to be itself chained with other eventHandlers.
*
* - DeviceEvent extends AsynchronousEvent.
* - FunctionChainStep is also available
*
* Here we get Device Snapshot information (includes upTimes and durationInState)
*/
@ThomasBurleson
ThomasBurleson / gist:1017230
Created June 9, 2011 17:26
Cool Techniques with AS3 Closures
// ------------------------------------------------------------------------------------------------
/**
* Why CLOSURES are great!
*
* Think of Closures as Functions within Functions... where nested functions have access to parent function variables
* and arguments. So, you may ask?
*
* Closures allow developers to temporarily cache data!
* Closures can simplify recursion or iterations (aka visitors pattern)
* Closures can solve real-world `callback` problems; especially powerful for asynchronous callbacks.
@ThomasBurleson
ThomasBurleson / gist:1019075
Created June 10, 2011 15:40
Popup Behavior for any Flex component
/**
* Add Popup Behavior to any Flex UI!
*
* 1) Want to show UI Components in Popup?
* 2) Want to use show/hide effects, autoClose, modality?
* 3) Want to use anchor constraints (top, right, etc.) to position the popup anywhere relative to ANY parent?
* 4) Want to position the popup relative to the mouse or any other specific location?
* 5) Want to cache the popup content for super-fast reuse ?
* 6) Want it super easy... with no need to worry about events or memory cleanup?
*
@ThomasBurleson
ThomasBurleson / gist:1034340
Created June 19, 2011 14:22
Popup Behavior used as Swiz Popup
/**
* Using Popup Behavior with Swiz and registerWindow()
*
* Source is available on GitHub project: Flex-Extensions
*
* https://github.com/CodeCatalyst/flex-extensions/blob/develop/src/com/codecatalyst/component/behavior/ui/Popup.as
*
*/
<?xml version="1.0" encoding="utf-8"?>