HBOGO in beta

Tags: , , , ,

HBOGO is HBO's ascent into syndicated online content. I spent 6+ months on this project, and after a healthy amount of work it has gone into beta and is looking beautifully. Please go give it a look.
Also check out a great friend and colleague who also worked on this site here






Flex List : ItemsChangedEffect - animation effects when adding and removing items in a list

Tags: , ,

Have you ever wanted the adding adding and removing of items to a list in flex to be more graceful, flashy, and interesting. There is an option, and it's really a great effect. List instances have itemsChangeEffect baked in. You use an instance of DefaultListEffect for this, and make sure you have variableRowHeights set to true, or you wont get the full effect of the animation. This has been around for a while, but I rarely see it used. You can see here - even with a list with 3000 instances

Here is the test application

Here is the source

A collection of classes outlining the most useful methods within PARSLEY

TAGS: None

While tinkering with Parsley I put together a straightforward collection of classes outlining the most useful / straightforward methods within parsley that will serve as a good reference when trying to find a specific way to inject / message etc without looking throughout the entire parsley docs. Attached is the source / project.

Here is a link to the reference

Below is an example of one of the classes. Please take a look at it as a reference.

 
package com.proving.receiver
{
import com.proving.event.MessageExtendingFromEventWithPayload;
import com.proving.event.MessageExtendingFromObjectWithPayload;
 
import mx.controls.Alert;
import mx.events.CloseEvent;
 
import org.spicefactory.parsley.core.messaging.MessageProcessor;
 
public class Receiver
{
public function Receiver()
{
}
 
private var processor:MessageProcessor
 
[MessageInterceptor(type="com.proving.event.MessageExtendingFromEventWithPayload")]
/**
 *This metadata allows you to intercept messages of specific types
 * This happens before any other methods handling this method are invoked
 * from this you can proceed or rewind
 * @param processor - MessageProcessor for this message
 *
 */
public function interceptEvent (processor:MessageProcessor):void {
	var message:MessageExtendingFromEventWithPayload = processor.message as MessageExtendingFromEventWithPayload;
	if(message.type == MessageExtendingFromEventWithPayload.DEFAULT_MESSAGE){
		this.processor = processor;
		Alert.show('Resume event invocations?', 'Alert!', Alert.YES | Alert.NO, null, closeHandler);
	}else{
		processor.proceed()
	}
}
 
[MessageError(type="com.proving.event.MessageExtendingFromEventWithPayload")]
/**
 *With this metadata you can handle messageError's that happen within the lifecycle of a message
 * This is useful because Errors within parsley are normally swallowed and simply logged leaving it hard to debug
 * This will handle errors that happen for specific types
 * please note : per my experience if you have a global message handler, specificly typed ones will not get fired subsequently
 * @param processor - MessageProcessor for this message
 * @param error - the error that was thrown in this
 *
 */
public function handleMessageErrorBySelector(processor:MessageProcessor, error:Error):void{
	trace('For MessageExtendingFromEventWithPayload : ' + error.getStackTrace());
} 
 
 [MessageError]
/**
 * With this metadata you can handle messageError's that happen within the lifecycle of any message
 * @param processor - MessageProcessor for this message
 * @param error - the error that was thrown in this
 *
 */
public function handleAllMessageErrors(processor:MessageProcessor, error:Error):void{
	trace('For all message errors : ' + error.getStackTrace());
} 
 
private function closeHandler(e:CloseEvent):void{
	if(e.detail == Alert.YES){
		if(processor)processor.proceed();
	}else{
		if(processor)processor.rewind();
	}
	processor = null;
}
 
[MessageHandler]
/**
 *Simple message handler, parsley does type matching to managed events here
 * This will handle all messages of type  MessageExtendingFromEventWithPayload
 * @param val - incoming message
 *
 */
public function handleMessageByClassType(val:MessageExtendingFromEventWithPayload):void{
	trace('received all managed messages of class type MessageExtendingFromEventWithPayload')
}
 
[MessageHandler(selector="messageExtendingFromEventWithPayload")]
/**
 *This metadata allows you to be more granular with which types of events within a message you will handle
 * @param val - incoming message
 *
 */
public function handleMessageBySelector(val:MessageExtendingFromEventWithPayload):void{
	trace('received all managed messages with type MessageExtendingFromEventWithPayload')
}
 
[MessageHandler(type="com.proving.event.MessageExtendingFromEventWithPayload", messageProperties="firstName, lastName")]
/**
 *This metadata allows you to similarly to messageBinding, parameterize a method with properties from an event with a payload
 * @param val - incoming message
 *
 */
public function handleMessageBySelectorWithParameterizedFunction(firstName:String, lastName:String):void{
	trace('received parameterized message of type MessageExtendingFromEventWithPayload')
}
 
[MessageHandler(selector="sendMessageWithError")]
public function handleMessageBySelectorAndThrowError(val:MessageExtendingFromEventWithPayload):void{
	throw new Error('Exercising Parsleys MessageError');
}
 
[MessageHandler]
/**
 *This method handler simply handles a message that does not extend from event
 * this can be useful for reasons of true decoupling
 * unlike with a message with an event, you can not get the target through this, making it truly decoupled
 * @param val
 *
 */
public function handleObjectMessage(val:MessageExtendingFromObjectWithPayload):void{
	trace('received all managed messages of class type MessageExtendingFromObjectWithPayload')
}
 
[MessageBinding(messageProperty="firstName",type="com.proving.event.MessageExtendingFromEventWithPayload")]
/**
 *This metadata allows you to do bindings through messsages
 * you associate a property on your message with the property you declare below the metadata
 */
public var firstName:String;
 
[MessageBinding(messageProperty="lastName",type="com.proving.event.MessageExtendingFromEventWithPayload")]
public var lastName:String;
 
}
}
 

Hope it helps

Eric

Replacing MessageHandler metadata in Parsley to add priority

Tags: , ,

Lately I've been getting very intimate with Parsley. Recently I was working on an issue where I wanted my messageHandlers within Parsley to have some concept of priority.

As Parsley works right now MessageHandlers (as far as you're concerned) are handled in an arbitrary order when you dispatch a message. Behind the scenes there is a finite order that messages are run in - based on when they were registered - but you as a client of Parsley don't have any inherent control when declaring MessageHandler metadata as you would when say - adding an eventListener.

One of the beautiful parts about Parsley is that the author Jens Halm gives you hooks into replacing all of the IOC Kernel services.

There kernel services that can be replaced as listed on his site are as follows.

CompositeContextBuilder Responsible for processing the configuration, creating ObjectDefinitions, and then building and initializing the Context. May be fed with different types of ObjectDefinitionBuilders, like the builtin ones for ActionScript, MXML or XML configuration.
Context This is the core interface of the framework, putting all the other pieces together and delegating most of the work to the other parts of the kernel listed below. It allows you to pull objects out of the container or examine its contents.
ObjectDefinitionRegistry The registry for all ObjectDefinitions the Context will manage.
ObjectLifecycleManager Responsible for processing ObjectDefinitions, instantiating, configuring and disposing the actual instances described by those definitions.
ScopeManager Responsible for managing all scopes that are associated with a single Context.
MessageRouter The core interface of the Messaging Framework.
ViewManager Responsible for dynamically wiring views to the Context.

This gives you massive power of injecting behavior as you see fit into an already very powerful framework, and this is what I used in order to replace and extend the existing [MessageHandler] metadata tag.

First, as Jens describes on his site, each of the IOC kernel services has a factory that implements it's own interface. Since there are no hooks to remove metadata that has already been registered within Parsley and no way to natively prevent it from being added, I decided to replace the classes he was registering Metadata with.

This was a three step process:

First I created the factory that is used to make the built in MetadataDecoratorAssembler.

 
package com.appdivision.parsleyTest.kernel{
import flash.system.ApplicationDomain;
 
import org.spicefactory.parsley.core.context.provider.ObjectProviderFactory;
import org.spicefactory.parsley.core.factory.ObjectDefinitionRegistryFactory;
import org.spicefactory.parsley.core.registry.ObjectDefinitionRegistry;
import org.spicefactory.parsley.core.registry.impl.DefaultObjectDefinitionRegistry;
import org.spicefactory.parsley.core.scope.ScopeManager;
 
public class ReplacementDefinitionRegistryFactory implements ObjectDefinitionRegistryFactory {
 
public function create (domain:ApplicationDomain, scopeManager:ScopeManager,
	providerFactory:ObjectProviderFactory) : ObjectDefinitionRegistry {
	return new DefaultObjectDefinitionRegistry(domain, scopeManager,
		providerFactory, [new ReplacementMetadataDecoratorAssembler(domain)]);
	}
 
   }
}
 

The main purpose of this as I mentioned before was to replace the built in MetaDataDecoratorAssembler with my own version called ReplacementMetadataDecoratorAssembler.

There was one reason and one reason only I wanted to replace this class - to remove where the MessageHandler metadata was originally being registered and add in my own line

Removed

Metadata.registerMetadataClass(MessageHandlerDecorator, domain);

Added

Metadata.registerMetadataClass(PrioritizedMessageHandlerDecorator, domain);

By adding the PrioritizedMessageHandlerDecorator we are able to add a class that is nearly identical to what had been previously implemented with one added property - 'priority'. It is also this class' responsibility to create the PrioritizedMessageHandler which will eventually populate the list Parsley iterates through when invoking the method handlers of messages. This object is passed the priority which is where it ultimately ends up living. Before adding this in Parsley used to internally instantiate MessageHandlers - these lacked the priority property - which is why we had to create our own.

public var priority:int;

After going through these steps there are only a couple more things we have to do

Firstly we create a new factory - but this time we're replacing the default Message router factory.

 
package com.appdivision.parsleyTest.kernel
{
	import org.spicefactory.parsley.core.factory.MessageRouterFactory;
	import org.spicefactory.parsley.core.messaging.ErrorPolicy;
	import org.spicefactory.parsley.core.messaging.MessageRouter;
	import org.spicefactory.parsley.core.messaging.receiver.MessageErrorHandler;
 
	public class ReplacementMessageRouterFactory implements MessageRouterFactory
	{
	private var _errorHandlers:Array = new Array();
	private var _unhandledError:ErrorPolicy;
 
	public function ReplacementMessageRouterFactory()
	{
	}
	public function get unhandledError():ErrorPolicy
	{
		return _unhandledError;
	}
	public function set unhandledError(policy:ErrorPolicy):void
	{
		_unhandledError = policy;
	}
	public function addErrorHandler(target:MessageErrorHandler):void
	{
		_errorHandlers.push(target);
	}
	public function create () : MessageRouter {
		return new ReplacementMessageRouter(_errorHandlers, unhandledError);
	}
 
	}
}
 

You can see here we've added a line to create a ReplacementMessageRouter. This is important because inside the message router parsley internally creates message processors - we also need to replace this in order to process messages based on their priority.

Inside of the ReplacementMessageRouter I replace the processor with this line

var processor:MessageProcessor = new ReplacementMessageProcessor(message, messageType, selector, _receivers, _unhandledError);

Inside the message processor I simply add a sort function that i call within the constructor. This method sorts the array of PrioritizedMessageHandlers based on their priority property.

 
function Processor (receivers:Array, handler:Function, async:Boolean = true, handleErrors:Boolean = true) {
	this.receivers = receivers;
	sort();
	this.handler = handler;
	this.async = async;
	this.handleErrors = handleErrors;
}
internal function sort():void{
	receivers.sortOn('priority', [Array.NUMERIC]);
}
 

Finally there is just one more step to set all of this in motion. Just before calling build() on your contextBuilder.

 
GlobalFactoryRegistry.instance.definitionRegistry = new ReplacementDefinitionRegistryFactory();
GlobalFactoryRegistry.instance.messageRouter = new ReplacementMessageRouterFactory();
FlexContextBuilder.build(Context, this);
 

When this is all done you can add message handlers to your methods with priority and Parsley will do it in that order.

[MessageHandler(priority = 0)]

All MessageHandlers without priority will be handled after ones that specify it.

Here is the source of what I did and a very simple example.

Debugging Parsley Messaging Errors

Tags: , , ,

When first starting to use Parsley the black-magic that is happening behind the scenes may confound some people.
Parsley purposely swallows runtime errors in order to not disrupts its messaging flow. You may see something like

 
DefaultMessageProcessor Message Target threw Error
 

The author of Parsley Jens Halm explains his reasoning behind this in this thread on the spicefactory forums

In larger application where Parsley messaging are kicking off complicated routines - the lack of detail that Parsley logs when swallowing errors can be prohibitive in finding the source of the Error - and if you don't know to look at your console the Errors will be effectively failing silently.

In Parsley 2.1 Jens introduced the [MessageError] metadata. This can be applied globally to all Errors that happen during the flow of a Parsley message or on a selector basis.

In our application we recently implemented a way through this new hook to catch and throw these errors - giving you valuable stack trace information - ultimately revealing the source of your Error. This makes it much easier to track down the source

 
package
{
        import org.spicefactory.parsley.core.messaging.MessageProcessor;
 
        public class ParsleyErrorBroker
        {
	    [MessageError]
	    public function handleError (processor:MessageProcessor, error:Error):void {
                throw error;
            }
        }
    }
}
 

After writing this class you have to add the following to your compiler arguments

 
-keep-as3-metadata=MessageError
 

Add this class to your Parsley Context - and you're set- after that all Errors will be routed to this class and thrown.

If you have any questions feel free to post below

PureMVC example - InterestsMediator - Efficient Notification Mapping

Tags:

I've been working with PureMVC for a while now. Like anything - there are parts I love, and parts a I really don't. One thing that becomes cumbersome is creating mediators for parts of the application that only have to handle one or two redundant notifications.
For this I set out to create a custom mediator to handle these type of situations across an application. I went ahead with several goals -- to keep the view decoupled from the framework, to be able to add and remove a views interest in a certain property, and to fix race conditions similarly to how bindings do.

For example, In the small example application I have attached at this bottom of this post there are three (color coded) sections all of which need to know about a property set in another section of the application. This is the only property these sections need to know from the application, and it would be overkill to instantiate mediators for every one of them. They instead use an InterestEvent to register themselves as a party interested in this event. They also implement an interface which extends from the IInterest marker interface and has a setter for the text. When the text is changed, the application mediator hears this and sends a notification. Inside the InterestsMediator you define the relationship between notification names and interfaces, so when a view declares it's interest through an event, the InterestsMediator creates a map of views that are interested in certain notifications.
The mapping occurs within the protected listNotificationMappings method.
Mappings look like this.

 
override protected function listNotificationMappings():Array{
return [
	{name : NotificationNames.MAIN_TEXT_CHANGE, type : ITextInterest, method : 'theText'},
	]
}
 

The views, for various reasons can also disassociate themselves as interested parties. Inside the example app you can the click the 'remove interest' button on different views and you'll see they no longer get updates, but as soon as you click the add interest button it will start receiving updates again. The interests aim to solve race conditions too, no matter how early or late a view component flags itself as an interested party it will receive the last value that had been been notified -- similarly to bindings.

The example app is by no means a best practices of PureMVC - but is a quick example of why this utility can be VERY useful inside a PureMVC app, not only to reduce code redundancy, but for code cleanliness, and race conditions

Here is the test application

Here is the source

  • Author: nick
  • Published: Oct 23rd, 2009
  • Comments: 5

Flex - Regex restricted TextInput component

Tags: , ,

If you've ever used the `restrict` property on the Flex TextInput control - you've probably wished that it was more than just a string property. While it does allow you to specify characters, and character ranges like A-Z or 0-9, it isn't nearly as convenient or as robust as a regex.

Here is a simple subclass of TextInput that implements the same functionality as `restrict` but using a regular expression.

View the sample application ...and the source code.

 
package com.appdivision.components
{
    import flash.events.TextEvent;
    import mx.controls.TextInput;
 
    public class RegexTextInput extends TextInput
    {
 
        private var _regex:RegExp;
 
        public function RegexTextInput()
        {
            super();
        }
 
        [Bindable]
        public function set regex(value:RegExp):void
        {
            if (value != _regex)
            {
                _regex = value;
            }
        }
 
        public function get regex():RegExp
        {
            return _regex;
        }
 
        override protected function childrenCreated():void
        {
            super.childrenCreated()
 
            addEventListener(TextEvent.TEXT_INPUT, handleTextInput);
        }
 
        public function handleTextInput(event:TextEvent):void
        {
            if (regex)
            {
                 // What the text will be if this input is allowed to happen
                 var textToBe:String = "";
                // Accomidate for a selection
                if (selectionBeginIndex > 0)
                {
                    textToBe += text.substr(0, selectionBeginIndex)
                }
                textToBe += event.text;
                if (selectionEndIndex > 0)
                {
                    textToBe += text.substr(selectionEndIndex, text.length - selectionEndIndex);
                }
                var match:Object = regex.exec(textToBe);
                if (!match || match[0] != textToBe)
                {
                    // The textToBe didn't match the expression... stop the event
                    event.preventDefault();
                }
            }
        }
    }
}
 

Enjoy.

Flex FULL-SCREEN utility

Tags: ,

This is a utility to use to ease the pain of going fullscreen in complicated applications. It is a static class that allows you to call goFullScreen() (with an optional parameter of background color) and exitFullScreen(). After calling goFullScreen() you can statically call addChild() and removeChild() just as if it was a UIComponent. The addChild method also allows you to pass optional parameters which will center horizontally or vertically, stretch proportionally, and set anchor point, to allow you to position the children through the fullscreen canvas. This effectively lets you completely build a new view expressly for use within fullscreen. When you call exitFullScreen, or press the escape key, the utility cleans up any children that have been added to it, and puts them back where they had been previously, maintaining all of their properties.
This utility can be especially advantageous with video players where the fullscreen version is much stripped down from the embedded version, since it lets you selectively add items to the fullscreen canvas, then puts them back for you automatically when you exit full screen.

Here is the source
and
Here is the demo which shows you how you can change the background color of your full-screen container and shows how you can selectively add items to it.

Feel free to use it

Thanks again and feel free to leave comments

Eric

New Flex e-commerce site launched : Ancient Industries!

Tags: ,

After many months of work we've launched a fully featured e-commerce site for Ancient Industries.
The site includes product configurations and inventory, images, cart, deep linking, as well as credit card checkout.
The main site can be seen at http://ancientindustries.com and the store can be seen at http://ancientindustries.com/shop
Please feel free to take a look, leave comments, or even do a little shopping

thanks!






Horizontal and Vertical alignment added to FlowContainer

Tags: , , ,

A long overdue update for FlowContainer. A lot of you have emailed me asking for verticalAlign and horizontalAlign to be added to the flowcontainer. A combination of be not being able to do it, and me not getting around to it has resulted in it not being done yet. But today one of my colleagues Curt Elasser decided to take on the task himself. I've put up the demo again with added comboBoxes to set the vertical and horizontal alignment. Feel free to take a look

Here is the source
and
Here is the demo

Feel free to use this in any project you want.

Thanks again and feel free to leave comments

Eric

  • bea goldfishberg
  • c span kozol
  • setup
  • la ink 105
  • la ink tattoos
  • chicago bears 2009 roster
  • search vim
  • stay
  • kenner
  • vince young rumors
  • search google cache
  • treasures
  • bengals images
  • oldsmobile
  • vince young 3rd 30
  • bengals 09 record
  • bangles eternal flame mp3bengals forum
  • hp support contact number
  • intercept
  • mtv youtube channel
  • zara phillips shoes royal wedding
  • cspan washington correspondents dinner 2011
  • locker
  • arboretum
  • lure
  • anual
  • tea party medicare
  • champs
  • vince young uncle rico
  • la ink price list
  • search and seizure
  • connecticut quarry
  • hp support contact us
  • tonight
  • hp support monitors
  • vince young 10 11
  • chad ochocinco 15
  • battleship aurora
  • bea diy
  • cspan journal
  • bengals 09
  • hp support chat
  • chicago bears 09 draft
  • tea party zombies download
  • hp support quick test pro
  • search engines other than google
  • tea party chicago
  • bea verdi
  • new england patriots wiki
  • randy moss wonderlic
  • chicago bears 96
  • chad ochocinco to detroit
  • vince young drunk
  • bea per capita income
  • chad ochocinco bears
  • coming
  • randy moss yahoo stats
  • bichon
  • battleship 3d game
  • chicago bears 08 record
  • randy moss korey stringer
  • vince young released
  • equals
  • hp support number united states
  • colt
  • cpanel
  • chicago bears 17 lisa lampanelli
  • freida pinto jeansfreida pinto kissing
  • chicago bears jewish players
  • repeaters
  • mtv jams
  • new england patriots 84
  • bea oracle
  • c span yesterdayc span zelaya
  • chicago bears schedule 2011
  • battleship history
  • la ink 3rd season
  • chad ochocinco xpchad ochocinco youtube
  • vince young injury
  • search 2.0
  • doppler
  • batt
  • search comcast net
  • utube
  • reveiws
  • hp support center
  • vince young jersey texas
  • knot
  • search engines and flash
  • cspan presidents
  • chad ochocinco to patriots
  • battleship classes
  • chicago bears 08 record
  • cemetery
  • hp support 6500a plus
  • burgers
  • freida pinto zac posen
  • search engines questions
  • 4pm cspancspan area 51cspan 90.1
  • search engines watch
  • battleship yamato 2010
  • duggan
  • greg olsen puzzles
  • millionaire
  • freida pinto 1995
  • options
  • bear gryllsbea hive dance studio
  • vince young dadvince young eagles
  • cocain
  • chicago bears 1985
  • choker
  • battleship aurora
  • new england patriots underwear
  • contest
  • bengals andy dalton
  • greg olsen university of miami
  • litre
  • search engines images
  • new england patriots store
  • bea luna
  • dist 95
  • search engines zuula
  • tea party ribbons
  • yukon
  • connecticut secretary of state
  • search engines visibility
  • greg olsen football
  • randy moss football cards
  • search engines for kids
  • la ink upcoming episodes
  • randy moss university
  • search engines internet
  • childern
  • mtv 30 years
  • suture
  • socom
  • new england patriots 80
  • cspan ap government review
  • xanadu bengals
  • zara phillips and the queen
  • zipper
  • bengals new uniforms 2012
  • hypothesis
  • hp support englandhp support forum
  • search engines cookiessearch engines definition
  • freezer
  • vince young redskins
  • chad ochocinco traded
  • search lsu.edu
  • search engines before google
  • search with image
  • freelander
  • vince young 2008
  • oshawa
  • mtv overdrive
  • vince young z
  • cspan kucinich
  • vince young stats
  • clubhouse
  • search 5500
  • connecticut football
  • new england patriots 50
  • la ink season 5 premiere
  • la ink 2011 season 5
  • zara phillips royal wedding picture
  • search xml file
  • bengals games
  • beamerbea france
  • debbie
  • freida pinto miral
  • greg olsen boulder
  • chicago bears 4th phase
  • hp support chat
  • vince young football camp
  • la ink book an appointment
  • la ink map
  • battleship texas hours
  • randy moss vikings 2011
  • battleship bismarck wreck
  • chad ochocinco quotes video
  • search jail inmates
  • hp support center
  • chicago bears bleacher report
  • couture
  • new england patriots helmet
  • tea party agenda
  • berry
  • cspan hosts
  • chicago bears garter
  • tea party 8 28 09