The following example shows how you can create a column chart as a component and invoke in application
by calling the getDefintionByName() method.
ChartDef.mxml
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” creationComplete=”createComplete(event)”> <mx:Script> <![CDATA[ import MyComps.*; import flash.utils.getDefinitionByName; import mx.controls.*; private var CC:PanelComp;ColumnCompChart // Initiate ColumnCompChart component. private function createComplete(e:Event):void { var cls:Class = getDefinitionByName(“MyComps.ColumnCompChart”) as Class; var instance:Object = new cls(); addChild(DisplayObject(instance) ); } ]]> </mx:Script> </mx:Application> |
ColumnCompChart.mxml
<?xml version=”1.0″ encoding=”utf-8″?> <mx:Panel xmlns:mx=”http://www.adobe.com/2006/mxml” width=”400″ height=”300″ title=”My Chart”> <mx:series> </mx:ColumnChart> |