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.

2 Responses to “Loading charts into another swf”

  1. admin Says:

    Since version line v 1.0.9 and column 0.9.5 for better results use “onLoadInit” instead of “onLoadComplete”

  2. Nano Surbakti Says:

    Greetings,

    Thanks for sharing. I have little experience in Flex/AS3, but not AS2. What I want to ask you: is it possible to do this (Loading charts into another swf) using MTASC only (without Macromedia Flash MX 2004 or Adobe Flash CS)?

    Thanks, again.

Leave a Reply

All support questions should be posted to support forums:
AmCharts: http://www.amcharts.com/forum/
AmMap: http://www.ammap.com/forum/