Sunday Feb 5

Archive for the ‘AS3’ Category

Dec
29/08
Subversion with Flex Builder 3
Last Updated on Monday, 29 December 2009 01:47
Written by Cody Snider
Monday, December 29th, 2008

I’ve got to say, working on SVN with Flex is great. The integration in Eclipse is fantastic. I found this great tutorial that really helped with the Flex end of things (though you’ll still need to get Subversion running on your own server or somewhere else…Google it).

Here’s that tutorial: Setting up Subversion with Adobe Flex 3

Tags: , ,   |  Posted under AS3  |  Comments  No Comments
Dec
06/08
EventDispatcher Interface in AS3
Last Updated on Wednesday, 14 April 2010 09:57
Written by Cody Snider
Saturday, December 6th, 2008

When you’re faced with the task of firing events from within a class and you can’t extend EventDispatcher, you need to implement the IEventDispatcher interface. It’s a straightforward approach to keeping your classes loosely coupled, well-encapsulated and capable of firing their own events:

View Code ACTIONSCRIPT
class YourClass implements IEventDispatcher {
 
   private var eventDispatcher:EventDispatcher = new EventDispatcher();
 
   public function YourClass() {
      // do constructor stuff here
   }
 
   public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void {
	eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
   }
 
   public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void {
	eventDispatcher.removeEventListener(type, listener, useCapture);
   }
 
   public function dispatchEvent(event:Event):Boolean {
	return eventDispatcher.dispatchEvent(event);
   }
 
   public function hasEventListener(type:String):Boolean {
	return eventDispatcher.hasEventListener(type);
   }
 
   public function willTrigger(type:String):Boolean {
	return eventDispatcher.willTrigger(type);
   }
}

All we’re really doing here is creating a private EventDispatcher object and hooking all its methods through public methods of your custom class.

Tags: , , ,   |  Posted under AS3  |  Comments  No Comments