The FCErrorEvent is an event which is triggered when an error occurs while rendering or manipulating a chart or widget using FusionCharts for Flex component. This allows you to determine the errors and take measures to counter them.
Let us try loading a Pie 3D chart whose SWF file is missing. In the following code we catch the FCErrorEvent event using an event listener, named errorHandler. The errorHandler alerts the error parameter. However, for practical cases you may counter the error, or further process the error to generate custom messages.
In order to generate this error you need to remove the corresponding SWF chart file from the chart folder (by default it is named fusioncharts). In this example we are trying to load Pie 3D. Hence, before running this example, please remove/rename Pie3D.swf.
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:components="com.fusioncharts.components.*" initialize="initApp()"> <components:FusionCharts id="FC1" FCChartType="Pie3D" FCDataURL="Data1.xml"/> <fx:Script> <![CDATA[ import com.events.FCEvent; import mx.collections.ArrayCollection; import mx.controls.Alert; private function initApp():void { FC1.addEventListener("FCErrorEvent",errorHandler); } private function errorHandler(e:FCEvent):void { Alert.show(e.param); } ]]> </fx:Script> </s:Application>
The above code shows an alert message (as shown in the image below) when the error is raised.