JavaScript charts Flex charts WPF & Silverlight charts Flash maps Flex maps
amCharts the best javascript charts *
Home Home
Products Products
Download Download
Buy Buy
FAQ FAQ
Documentation Documentation
Support forum Support forum

2007-03-21 Loading charts into another swf

You can load any chart in to another swf file. The following example is made for Line & Area chart, However you only need to change all occurrences of "amline" to "amcolumn" or "ampie" or "amxy" and this will work for other charts. Here is the code, copy and paste it to your flash movie:

var listener:Object = new Object(); listener.onLoadComplete = function(target_mc:MovieClip):Void { target_mc.path = "amline/"; target_mc.settings_file = "amline/amline_settings.xml"; target_mc.data_file = "amline/amline_data.xml"; target_mc.flash_width = "550"; target_mc.flash_height = "400"; } var loader:MovieClipLoader = new MovieClipLoader(); loader.addListener(listener); this.createEmptyMovieClip("amline_mc", this.getNextHighestDepth()); loader.loadClip("amline/amline.swf", this.amline_mc);

With current settings your swf file should be saved in the same folder where amline.html is. Do not forget to change paths if you save it to a different location.

When chart is loaded to your parent swf, stage alignment will be changed to "TOP-LEFT". if you don't want this to happen, add this line to you onLoadComplete function:

target_mc.align = "";

The same with scaling - if you don't want to use "noScale", add this line:

target_mc.scale = "";

Download example loader.fla file.


amCharts for WPF RSS feed Subscribe to our RSS feed to be notified about new releases and updates.
<< Previous | Next >>
© amCharts | About us | Contact and feedback: info@amcharts.com Subscribe to amcharts news feed by e-mail or RSS reader Follow amCharts on Twitter * many people say so ;)