flex3: Category
Category: flex3
Ouch, it hurts when i do that
Posted At: March 10, 2010 2:03 PM | Posted By: Jeff Tapper
Related Categories: actionscript3, as3, flash, flash9, flashplayer, flex, flex3, flex4, fp10, Speaking Conferences
Flex 4 for Flex 3 developers
Posted At: February 26, 2010 2:02 PM | Posted By: Jeff Tapper
Related Categories: flash, flashplayer, flex, flex3, flex4
Flex 360 tickets selling fast
Posted At: December 17, 2009 12:12 PM | Posted By: Jeff Tapper
Related Categories: actionscript3, flash, flashplayer, flex, flex3, flex4, FlexUnit4, fp10, fp9, Speaking Conferences
Fun with custom preloaders in Flex
Posted At: October 2, 2009 11:10 AM | Posted By: Jeff Tapper
Related Categories: actionscript3, as3, flash9, flex, flex3, fp10, fp9
package net.digitalprimates.preload
{
public class PreloadEventBus extends EventDispatcher
{
public var isReady:Boolean = false;
private static var _instance:PreloadEventBus;
public static const READY:String = "READY";
public static function getInstance():PreloadEventBus
{
if (!_instance)
{
_instance = new PreloadEventBus(new SingletonEnforcer());
}
return _instance;
}
public function PreloadEventBus(singletonEnforcer:SingletonEnforcer)
{
if (!singletonEnforcer)
{
throw new Error("PreloadEventBus is a singleton class, use getInstance() instead");
}
}
}
}
class SingletonEnforcer {}
With this class, when the main application is done with its startup procedure, it’s a simple process to get a reference to the PreloadEventBus, set isReady to true, and dispatch an event.
protected function applicationCustomStartupDone(event:Event)
{
var bus:PreloadEventBus = PreloadEventBus.getInstance();
bus.isReady = true;
bus.dispatchEvent( new Event ( PreloadEventBus.READY );
}
In the custom preloader, you can override the set preload method, and instead of listening for the complete event as the base class does, listen for the INIT_COMPLETE event, which indicates that the application has loaded, and had its initialize event dispatched. In the event handler for this method, you will get a reference to the PreloadEventBus, check if the application has already set the isReady flag to true, and if not, listen for the READY event.
private function bus:PreloadEventBus = PreloadEventBus.getInstance();
override public function set preloader( value:Sprite ):void
{
preloader.addEventListener( FlexEvent.INIT_COMPLETE , initComplete);
}
An important thing to note is the lack of call to super.preloader in this overridden setter. If the base classes setter is allowed to run, the preloader will act as initially intended, such that it disappears when the application is done downloading. As the purpose of this preloader is to allow for the application to determine when to hide the preloader and start the app, its important we override this functionality. You may find that you need to listen for other events here, such as ProgressEvent.PROGRESS, FlexEvent.INIT_PROGRESS or Event.COMPLETE. This example shows the bare minimum you would need to make use of the preloader
private function initComplete( event:Event ):void
{
if (bus.isReady)
{
completePreloader(event)
}
else
{
bus.addEventListener(PreloadEventBus.READY, completePreloader);
}
}
While its not expected that the application will be done with its initialization procedures before the INIT_COMPLETE, but, based on how the application is built, it is possible. To avoid this race condition, the isReady property of the PreloadEventBus is used, so that the preloader only listens for the READY event if the application is not already done with its startup. Last but not least is the completePreloader method, which is called when the preloader has determined that the application is ready. With the logic in initComplete, this same method will be used, regardless whether the state of the application was determined by the isReady property, or by listening for the PreloadEventBus.READY event.
private function completePreloader(event:Event):void
{
dispatchEvent( new Event( Event.COMPLETE ) );
}
Event.COMPLETE is used, as this is the event for which the system manager listens, to know that the preloader is done with its job. By preventing its normal mechanism of dispatching, and only dispatching it when the application determines it is ready, you have a nice clean approach to allow the the preloader to display as long as it needs to.
FlexUnit 4 feature overview
Posted At: May 20, 2009 9:05 AM | Posted By: Jeff Tapper
Related Categories: actionscript3, AIR, as3, flash, flashplayer, flex, flex3, FlexUnit4, Fluint
How not to code Flex Applications
Posted At: May 19, 2009 5:05 PM | Posted By: Jeff Tapper
Related Categories: actionscript3, adobe, flash, flex, flex3
Flex Camp Chicago
Posted At: January 22, 2009 4:01 PM | Posted By: Jeff Tapper
Related Categories: cfmx7, ColdFusion, flex, flex3, Speaking Conferences
Flex Camp 360 NJ
Posted At: October 7, 2008 9:10 PM | Posted By: Jeff Tapper
Related Categories: actionscript3, adobe, AIR, as3, flex, flex2, flex3, FlexUnit
File this under the better late than never…
On September 26 and 27th, the folks who bring you Flex 360, put on a 2 day "Flex Camp" in New Jersery, which went over extremely well. I was presenting on Testing with Fluint (formerly known as DPUint). Of course, I promised my slides and materials would be up on here before the end of the weekend. Well, realizing its over a week later, I'm finally getting them uploaded now.
So, if you were one of the many asking for those materials, here they are.
You can stop waiting, its been released.
Posted At: April 9, 2008 9:04 PM | Posted By: Jeff Tapper
Related Categories: actionscript3, adobe, as3, books, flex, flex3, ria
CFUnited Europe, AJAXWorld, and more conference stuff…
Posted At: March 4, 2008 7:03 AM | Posted By: Jeff Tapper
Related Categories: actionscript3, adobe, AIR, ajax, cfmx7, cfunited, ColdFusion, flex, flex3, Speaking Conferences