2xs Report post Posted December 31, 2008 Is it possible to load a AS2 Fusion Line Graph Line.swf in a Flash CS3 Movie? I managed to load a AS2 Fushion Line Graph Line.swf in a CS3 Movie but get the data loading data error text. If this is not possible will the FushionCharts v3 developer licence version allow me to achieve this? Share this post Link to post Share on other sites
dbasix Report post Posted January 1, 2009 (edited) Create a Chart Loading class and named it ChartLoader.as package { import flash.display.*; import flash.events.*; import flash.net.URLRequest; // 3rd party API for AVM1-AVM2 communication as our charts are on flas 8 AVM1 version and // Flash 9 runs on AVM2. AVM stands for Actionscript Virtual Machine. import flx.external.FlashInterface; // Main Chartloader class public class ChartLoader extends Sprite { private var loader:Loader; private var Xpos:Number,Ypos:Number; private var Id:String; // Chartloader constructor public function ChartLoader(chartURL:String,XMLurl:String,XMLdata:String,chartWidth:Number,chartHeight:Number,xpos:Number,ypos:Number) { // Initialisation of varibles with supplied data. // chartURL - path of the chart swf //XMLurl - URL of the supplied data xml file //XMLdata - Supplied xml data as string // chartwidth, chartheight - specified width and height of the chart // xpos, ypos - x and y position of chart on stage. this.Xpos=xpos; this.Ypos=ypos; // Unique ID to separate and identify each chart object. Id=this.name; // Instantiation of Loader class. loader = new Loader(); // EventListener to track the completion of chart loading process loader.contentLoaderInfo.addEventListener(Event.INIT, loaded); // URLRequest instantiation by passing swf path and params var urlRequest:URLRequest = new URLRequest(chartURL+"?flashId="+Id+"&defaultdatafile="+XMLurl+"&dataXML="+XMLdata+"&chartwidth="+chartWidth+"&chartheight="+chartHeight+"&mode=flex"); // Loading of chart in loader loader.load(urlRequest); } // This function will execute after completion of loading of each chart private function loaded (e:Event):void { trace("loaded"); // Addition of loader object with dispaly child. addChild(loader); // Positioning of chart loader.x=Xpos; loader.y=Ypos; // Dispatching of event to track down the load of charts from outside dispatchEvent(new Event("chartInitialized")); } // setDataXML function to update the chart. // Arguments needed as XML string public function setDataXML(dataxml:String):void { FlashInterface.call(Id+".setDataXML",dataxml); } // Call setDataURL function from outside to update chart. // Argument as a URL string of a specific xml file. public function setDataURL(dataurl:String):void { FlashInterface.call(Id+".setDataURL",dataurl); } // Function to call saveAsImage from outside public function saveAsImage():void { FlashInterface.call(Id+".chart.saveAsImage"); } // Function to call printChart from outside public function printChart():void { FlashInterface.call(Id+".chart.printChart"); } } } And from Flash, use it like bellow- // Import the ChartLoader class import ChartLoader; // Demo XML data for setDataXML method. var xmlData:String=""; var xmlData_2:String=""; // ChartLoader instance creation var chart1:ChartLoader=new ChartLoader("charts/Line.swf","",xmlData,400,300,0,0); // Object added to Stage stage.addChild(chart1); // ChartLoader instance creation var chart2:ChartLoader=new ChartLoader("charts/Line.swf","data/chartData.xml","",400,300,410,0); // Object added to Stage stage.addChild(chart2); // Event listener for mouse event this.addEventListener(MouseEvent.CLICK,changeData); //Button click functions and chart function invocation function changeData(e:MouseEvent):void { switch(e.target.name) { case "buttA1": chart1.setDataXML(xmlData_2); break; case "buttA2": chart1.setDataURL("data/Data_2.xml"); break; case "buttB1": chart2.setDataXML(xmlData_2); break; case "buttB2": chart2.setDataURL("data/Data_2.xml"); break; default: trace("No job specified !"); } } Thanks. Edited January 1, 2009 by Guest Share this post Link to post Share on other sites
2xs Report post Posted January 1, 2009 Hi dbasix The Graph loads fine initially but when I click the button to update I get an error. Thanks for the help, just one problem // Call setDataURL function from outside to update chart. // Argument as a URL string of a specific xml file. public function setDataURL(dataurl:String):void { trace("ID = "+Id); trace("FlashInterface = "+FlashInterface); trace("Data Url = "+dataurl); FlashInterface.call(Id+".setDataURL",dataurl); } I get this error ID = instance86 FlashInterface = [class FlashInterface] Data Url = data/Data.xml TypeError: Error #1009: Cannot access a property or method of a null object reference. at flx.external::FlashInterface$/call() at code.maps::ChartLoader/setDataURL() at MapService_fla::MainTimeline/changeData() Share this post Link to post Share on other sites
dbasix Report post Posted January 5, 2009 May be u are not using FlashInterface (a third party API) or AS3 specific chart swf file. You can find those special chart swf file in 'FusionCharts for Flex' on www.fusioncharts.com/flex . I have attached the FlashInterface API. Thanks. FlashInterface.zip Share this post Link to post Share on other sites
Pallav Report post Posted February 19, 2009 Or, you can use the commercial FusionCharts for Flex at www.fusioncharts.com/flex Share this post Link to post Share on other sites
Guest Rajroop Report post Posted July 3, 2009 Hello , We are really excited to announce the release of FusionCharts for Flex v1.1 featuring the following: - 12 new chart types: 7 new gauges including Angular gauge, LED gauge and Linear gauge, Spark chart and Bullet graphs have been added. - All the gauges can fetch data in real-time and come with alert managers and message loggers. - All the charts and gauges can now be natively exported as images and PDFs. - The data for all the charts can be exported as CSV. - Data sets can now have custom text labels instead of numeric values. - The charts can handle a lot more events to help you manipulate them better. - Trendlines can also have custom tool-text. - Custom color palettes can be defined for the data plots. Learn more about it from www.fusioncharts.com/flex. and learn what's new in FusionCharts for Flex from http://www.fusioncharts.com/flex/VersionHistory.asp. Existing customers can upgrade to the new version from www.fusioncharts.com/PUC. Share this post Link to post Share on other sites