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:
- Part 1: Introducing components
- Part 2: MenuBar component prototype
- Part 3: From prototype to component
- Part 4: Events
- Part 5: Styles and skins
- Part 6: Invalidation model
- Part 7: Focus management
- Part 8: Keyboard support
- Part 9: Shim compiled clip
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(); }
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?). Read the rest of this entry »