Something Wrong with the System

A Flash/Actionscript blog

Making AS3 components is harder than I’d imagined…

UPDATE
I’ve updated the Flash Pie Chart, made it more awesome and put it up for sale on ActiveDen as a Flash component and Flex Class!
Check it out! It’s pretty rad!



So as I wrote earlier I’m working on transforming my 3D Pie Chart into a proper AS3 component.  Holy crap, it’s harder than I thought!

By far the most useful resource I’ve found is this one written by Jeff Kamerer from Adobe.  The document is divided into 9 parts (it’s a small book!) and covers:

I’ve trudged my way through the first 3 parts and… GREAT SUCCESS!  I’ve got my Pie Chart publishing from a component inspector window (shown on the left).

The bit of code that caused me the most grief is the section that pertains to the dataProvider.  It seems that if I want custom parameters in my Component Inspector I need to create my own DataProvider classes.

[Collection(collectionClass="ca.organa.Data.Collect", collectionItem="ca.organa.Data.ComponentInfo", identifier="sliceLabel", name="Pie Chart Data")]
 public function set dataProvider(value:Collection):void {
 if (_dataProvider != null) {
  _dataProvider.removeEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange);
 }
  _dataProvider = value;
  _dataProvider.addEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange, false, 0, true);
  invalidate();
 }

Jeff covers the topic here.

I’ll post about components again once I’ve gone further into this stuff.  My next challenges are going to be getting live preview working, and getting a proper colour picker in the component inspector (is that even possible?).

September 8th, 2009 by Peter Organa

Comments are closed.