Hi All,
I have a FusionChart app to render charts according to FCDataURL.
I put the app under apache in CentOS 6.2, and it will work correctly if I access it by FireFox in Windows.
However, when I access it in CentOS 6.2, a FCErrorEvent will be thrown:
FusionCharts for Flex needs External-Interface for cross AVM communication between your Flex project and the charts.It seems that you've not set Flash security permissions for this folder on your file system. As such, External-Interface is unable to initiate a connection. Please refer to "FusionCharts for Flex" documentation on how to set proper security permissions for your folder.
It seems to be the permission issue, but the error still occurs even when I logon as root.
Could you please help to solve the issue? Thanks.
Here is my code:
<?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" maxWidth="800" maxHeight="240" minWidth="800" minHeight="240"
xmlns:ns1="com.fusioncharts.components.*" initialize="initializeFunction()">
<ns1:FusionCharts id="myChart" width="100%" height="100%"
FCDataURL="{_url}" FCChartType="{_chartMode}"
FCRenderEvent="exportSnapShot()" FCLoadEvent="_loadevent(event)" FCDataLoadedEvent="_dataloadedevent(event)"
FCDataLoadErrorEvent="_errorevent(event)" FCErrorEvent="_errorevent(event)"></ns1:FusionCharts> <fx:Script>
<![CDATA[
import com.events.FCEvent;
import com.fusioncharts.components.FusionCharts;
import flash.utils.ByteArray;
//import lib.UrlEncodeDecode;
import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.graphics.codec.PNGEncoder;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import mx.utils.Base64Encoder;
import mx.utils.URLUtil;
private var _parameter:Object;
private var _writerURL:String;
private var _outputFilename:String;
private var _dataURL:String;
private var _chartSetting:String;
private var _httpService:HTTPService;
[bindable]
private var _chartMode:String;
[bindable]
private var _url:String;
private var _retry:int = 0;
private function exportSnapShot():void
{
ExternalInterface.call('console.log', 'exportSnapShot');
var largeBmpData:BitmapData = new BitmapData(myChart.width, myChart.height);
largeBmpData.draw(myChart);
var largeBytArr:ByteArray = new PNGEncoder().encode(largeBmpData);
var largeEnc:Base64Encoder = new Base64Encoder();
largeEnc.insertNewLines = false;
largeEnc.encodeBytes(largeBytArr);
var snapshotData:Object= new Object();
snapshotData.bdata= largeEnc as Object;
snapshotData.filename = _outputFilename;
// Call the middleware to send the snapshot and save it
_httpService = new HTTPService();
_httpService.url= _writerURL;
_httpService.method= "POST";
_httpService.request= snapshotData;
_httpService.addEventListener(ResultEvent.RESULT, finish);
_httpService.addEventListener(FaultEvent.FAULT, wrongfinish);
// ExternalInterface.call('console.log', 'before send');
_httpService.send();
}
private function initializeFunction():void
{
ExternalInterface.call('alert', 'init0');
var urlCoder:UrlEncodeDecode = new UrlEncodeDecode;
_parameter = FlexGlobals.topLevelApplication.parameters;
if (_parameter && _parameter.write && _parameter.output && _parameter.dataURL && _parameter.chartSetting)
{
_writerURL = urlCoder.UrlDecode(_parameter.write);
_outputFilename = urlCoder.UrlDecode(_parameter.output);
_dataURL = urlCoder.UrlDecode(_parameter.dataURL);
_chartSetting = urlCoder.UrlDecode(_parameter.chartSetting);
_chartSetting = "seriesEntry=&topN=0&avgPeriod=1335395479:1335409879&merge=0&isMulti=0&fa=LogTime&showBorder=0&isXml=1&fieldLabel=LogTime&threshold=1&displayBaseline=0&chartType=chart_line&yaxis=count&showLabel=1&dateGap=h&basedBy=average&chartMode=MSLine&displayData=all&seriesField=";
// Extract chart Setting parameters
var settingObj:Object = URLUtil.stringToObject(_chartSetting, "&");
_url = _dataURL + "&stageWidth=" + this.width.toString() + "&" + _chartSetting;
_chartMode = settingObj.chartMode;
//ExternalInterface.call('alert', _url);
}
}
private function finish(e:ResultEvent):void
{
ExternalInterface.call('console.log', 'finished');
if (_retry > 0)
ExternalInterface.call('console.log', 'Retried ' + _retry + ' times...');
ExternalInterface.call('finished');
}
private function wrongfinish(e:FaultEvent):void
{
ExternalInterface.call('console.log', 'Cannot send image back to server. Error: ' + e.toString());
if (_retry > 0)
ExternalInterface.call('console.log', 'Retried ' + _retry + ' times...');
ExternalInterface.call('finished');
}
private function _dataloadedevent(e:FCEvent):void
{
ExternalInterface.call('alert', 'data loaded');
}
private function _loadevent(e:FCEvent):void
{
ExternalInterface.call('alert', 'load event');
}
private function _errorevent(e:FCEvent):void
{
ExternalInterface.call('console.log', 'Fusion Chart Error. Event type: ' + e.type + '. Error: ' + e.param);
if (_retry < 3) {
var __tmp:String = _url;
_url = '';
_url = __tmp;
_retry++;
myChart.FCRender();
} else {
ExternalInterface.call('console.log', 'Retried 3 times, exiting. Event type: ' + e.type + '. Error: ' + e.param);
ExternalInterface.call('finished');
}
}
]]>
</fx:Script></s:Application>
Regards,
Scott