amCharts Documentation
Search:     Advanced search
Browse by category:

Loading the Chart into Another Flash Movie

Views: 890

Loading the Chart into Another Flash Movie

Normally, the chart is embedded in HTML. However you can load it as a movie clip inside another Flash movie. This requires knowledge of Macromedia Flash!

To insert the chart into your movie, paste the following code snippet into your Flash project:

var listener:Object = new Object();
 
listener.onLoadInit = function(target_mc:MovieClip):Void {
    target_mc.path = "ampie/";
    target_mc.settings_file = "ampie/ampie_settings.xml";
    target_mc.data_file = "ampie/ampie_data.xml";
    target_mc.flash_width = "550";
    target_mc.flash_height = "400";
}
 
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
 
this.createEmptyMovieClip("ampie_mc", this.getNextHighestDepth());
loader.loadClip("ampie/ampie.swf", this.ampie_mc);
This code can work without modification under two conditions:
  • You are using the default file and folder names, as they are in the amPie distribution package.
  • Your larger Flash file is located in the same directory as the web page file.

If this is not the case, you will need to change the paths and file names in the code snippet above.

Alignment and scale

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 = "";

You can find an example of the loader file here.

Showing: 1-2 of 2  
Comments

21 Jan, 2008   |   marcelionis
amCharts are programmed with AS2, and I am afraid there is no way to load them to flash file compiled with AS3


19 Jan, 2008   |   atle
Do you have any examples for AS3? Preferrably showing how to pass parameters from within the actionscript file, not via external files.


Others in this Category
document Javascript Controls
document Image Export Scripts