Choosing a Widget Framework: Widget Factory vs. CpGears

Rumble

Widget Factory 5.1 has just been released and it is a very good and stable platform for developing your widgets.  In fact, the majority of the widgets that I’ve built are based on the Widget Factory (WF) framework. 

CpGears is another great widget framework that handles things much differently than Widget Factory.  I’m going to highlight some of the good things about CpGears in relation to Widget Factory.  You can decide which is better for you.

 

Widget Lifecycle

If you’ve developed widgets for Adobe Captivate, you probably have a workflow you either follow consciously or subconsciously.  After building a few of my own, I started to realize that I was creating movie clips on the stage to manage the lifecycle stages for a widget (a.k.a. views):

lifecycle

  1. Preview – the small preview of the widget in the widget panel
  2. Edit View – where the Cp Author configures your widget, setting its properties
  3. Stage View – when the widget “sits” on the Cp canvas after setting its properties
  4. Runtime View – where the widget comes “alive” during Cp playback

Workflow

This lifecycle workflow becomes unavoidable.  Both frameworks approach this lifecycle very differently.  Widget Factory allows you to override template methods (enterStage, enterPropertiesDialog, etc) within the same .as file.  The .as file becomes very cluttered and a single widget could easily have over a thousand lines of code.  If you’re familiar with OOP (object oriented programming), you could break out your logic into separate .as file classes, but that’s up to the developer.  It is also your responsibility to manage the visibility of these movie clips or “views” during the lifecycle of the widget.  So you end up having to manually hide the preview, edit view, and stage view while in runtime view.  In addition, all of my movie clips that managed my views were all sharing the same overcrowded Flash stage.  In order to edit one, I’d have to hide or move the others out of the way.  Images of MMA fighting in the Stage Cage suddenly came to mind:

Stage-Rage.pgg CpGears automates this lifecycle for you.  Using the SimpleViewManager, it is smart enough to know when to hide or show your different movie clips or views.  In fact, your movie clips are also attached to a separate class so that the code behind .as file and the UI are “grouped” according to your views.  The Preview movie clip has its own .as class file, the Edit view movie clip has its own .as class file, the Stage view movie clip has its own .as class file, etc..  This allows you to quickly edit the code for that particular view and nicely organizes your project.  Since these views have their own movie clip and class, it does not clutter the Flash stage either.  CpGears is definitely easier to use and organize when it comes to managing the lifecycle of the widget.  CpGears was built with managing the widget lifecycle in mind making life for the developer much easier.

Stage-of-worship

 

Strong Typing & Intellisense

When using Widget Factory, you’ll notice that the IDE doesn’t suggest items when using the properties object to store your widget properties.  This is because the properties object is not strongly typed.

CpGears, on the other hand, has a widget properties class that has strongly typed objects so you do get intellisense or suggestions as you type your AS3 code in the Flash IDE.  You will also get compile time errors if something is not typed correctly instead of hard-to-find run time errors with Widget Factory.  This feature has saved my butt numerous times already!

Intellisense

Debugging

If you’ve developed a widget, you know that the conventional trace(); method doesn’t work well since you’re inside the Captivate environment when testing your widget.  CpGears has a built in Logging framework, Log5F, that uses an Arthropod appender to view debug messages for all stages of the widget’s lifecycle.  The cool part is that you can assign categories to your log messages so that you can identify log message to a specific class.  This helps you narrow down your bugs much faster.

classIdentification If you want logging / debugging in Widget Factory, you must add it manually as described in this article.  The example uses DeMonster debugger which I have found sometimes works… and sometimes doesn’t.  Since all your AS3 code will typically be in one .as class file, you’ll have to dig through all of it to find the problem.

 

Widget Visibility

Widget visibility in Captivate is like the elusive wild jackalope.  You would think it’s as simple as widget.visible; but what if the Learner scrubs the playhead on the playbar allowing your widget to become visible again?  What if the Captivate Author uses an advanced action to hide or show your widget?  If you’re using Widget Factory, you have to manually detect these possibilities.  With CpGears, there’s a built in event you can tap into that automatically fires if the widget’s visibility has changed.  No jackalopes were injured or mistreated during the making of this image… well… maybe a little!

Widget-Visibility

Variable Monitoring & Events

Widget Factory has the standard set of events to choose from (enterSlide, exitSlide, enterMovie, etc…).  CpGears has similar events but goes a step further giving you the ability to monitor your own variables.  If you want to monitor when a text entry box user variable has changed, you can monitor something like the “text_entry_box_1” variable.  Want to monitor when playbar visibility has changed?  You can monitor the “cpCmndShowPlaybar” variable.  You can monitor any Captivate variable which makes CpGears very versatile.  By default, CpGears doesn’t monitor any variables until you tell it to. It will start the monitoring process only when a variable is added to the monitoring function saving CPU resources.

MonitoredVariable

Which One is Better?

The fact remains that there isn’t a right or wrong answer here. A lot of it depends on the environment, project and skill set of the Widget Developer. So, no…I won’t tell you what I suggest because I don’t know the requirements and environment you work in. That’s why they pay you the big bucks to be a widget developer, right?

Personally, I will be switching to CpGears for the benefits mentioned above.  However, if I need a widget that needs to be compatible with Cp4 and Cp5, I’d choose Widget Factory.  CpGears is for Cp5 widgets only.  Both frameworks have their rightful place depending on the project requirements and the skill set of the Widget Developer.

Peace

  • http://www.flash-factor.com Whyves

    Hey Jim,

    Very nice article and so funny at that. I love those pictures! Thanks for talking about some of the features of CpGears. By the way, you can also monitor the standard Captivate Events for entering and leaving a slide through CpGears. I will update the Event article in the Wiki section to show how one can use them.

    Yves

  • Pingback: Flash-Factor » Blog Archive » CpGears is 6 months old