Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Burleson ThomasBurleson

View GitHub Profile
@ThomasBurleson
ThomasBurleson / ItemRendererFactory.as
Created Feb 11, 2011
Flex - Refactoring of UIClassFactory
View ItemRendererFactory.as
////////////////////////////////////////////////////////////////////////////////
//
// 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 Mar 28, 2011
BabelFx - Use of XML to dynamically build MenuBar solution.
View gist:890676
<?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 Mar 28, 2011
Flex ItemRenderers - global data usages
View gist:891377
<?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 Apr 18, 2011
Swiz Metadata XML - Adapted for use in FB4 SWCs
View gist:925645
<?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 Apr 26, 2011
Supplant for AS3 [no more StringUtils.substitute]
View gist:941711
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
AS3 Functional Programming to Convert String list to BitFlags
View gist:972665
"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
Swiz EventChains with conditionals
View Chaining with Async Events
[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 Jun 9, 2011
Cool Techniques with AS3 Closures
View gist:1017230
// ------------------------------------------------------------------------------------------------
/**
* 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 Jun 10, 2011
Popup Behavior for any Flex component
View gist:1019075
/**
* 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 Jun 19, 2011
Popup Behavior used as Swiz Popup
View gist:1034340
/**
* 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"?>