Sign in to follow this  
Dlyttle

Exporting or Printing from Standalone Flash Application

Recommended Posts

OK ... I'm lost! I want to use the export images and print capabilities of Fusion Charts (and especially Power Charts) from a Flash standalone application, but I can't find any examples or "how to" do it. I've found all kinds of stuff about server side-client side and charts embedded in HTML pages ... but NOTHING about how to use those capabilities in standalone Flash.

Am I blind, blonde, just plain dumb ... or, can you even do these things (Lord, I hope so since that's why I spent $500 USD on this to begin with) in a standalone Flash application???

PLEASE HELP SOON!

Thanks in Advance,

... Don

Share this post


Link to post
Share on other sites

Hello,

 

 

 

It is possible to export images/print charts from a flash standalone application.

 

 

 

If you are using Flash 8 you cannot Print/Export directly. You will need to use our server side export handlers.

 

 

 

If you are using Flash 9 you need to load our chart SWF files from FusionCharts for Flex (www.fusioncharts.com/flex) and then take a snapshot of the loaded SWF (SWFLoader) in the code.

 

 

 

Hope this helps. :)

Share this post


Link to post
Share on other sites
If you are using Flash 9 you need to load our chart SWF files from FusionCharts for Flex (www.fusioncharts.com/flex) and then take a snapshot of the loaded SWF (SWFLoader) in the code.

I'm using Flash CS4 with AS2 actionscript. Although I've worked with Flash for many years, I have no idea what you're talking about with the statement you make above ("take a 'snapshot' of the loaded SWF").

Exactly how do I do all this? Where's an example I can look at to see specifically what I have to do to print and export? Right now, getting this thing to export (hopefully PDF) is of primary importance (as you'll see below, I'm close to having the print capability working). Can you show me a specific example, or outline the export process for me, or share more detail than what you have above?

Meanwhile, I have kind of figured out how to print (at least I think so). Except I've got a strange issue where the "Print Chart" shows up in the right-click context menu only when I click on certain areas of the Waterfall chart (the data columns and the darker colored areas of the alternating horizontal bands on the canvas of the chart for instance). On other areas, such as the lighter (white colored) horizontal background bands behind the data plot columns, when I right click I only get the standard Flash contect menu with "Print" as one of the options.

I'm getting a bit desparate since my customer is expecting this to be complete and in his hands by Monday. PLEASE HELP!!!

Thanks ... Don

Share this post


Link to post
Share on other sites

Hi,

Are you loading the charts from SWF files or creating the charts from .as class files?

Since you are using Flash CS4, for export what you can do is:

1. Get the charts from FusionCharts for Flex package (www.fusioncharts.com/flex) which helps you to load FusionCharts (build in AS2) swf files to load in AS3 (AVM2) program.

2. Create the chart using AS3

3. Get the image data (snapshot) of the chart:

code hint:

bmp:BitmapData=new BitmapData(this.width,this.height,true);

var matrix:Matrix = new Matrix();

bmp.draw(this, matrix);

4. Use some image encoder classes (many freely available) to encode the BitmapData object to a ByteArray containing the binary of an image format:

jpg:JPEGEncoder=new JPEGEncoder(100); // 3rd party JPEGEncoder class

imgData=jpg.encode(bmp);

5. Finally use flash.net.FileReference.save() to let the user download the exported format.

-------------------------------------

To print please use the PrintManager class of AS3 and print the desired location.

Hope this helps :) wishing you luck in finishing you project fast.

Share this post


Link to post
Share on other sites

I am loading the charts from SWF files ... exactly the way you do in the sample Flash examples you give in "FusionCharts_Developer_v3_1_1FusionCharts_DeveloperCode" folder that came with the software I purchased. Matter of fact, I took one of the examples and simply modified it (using a Waterfall Chart) to get what I needed.

Why do I have to go through all that stuff you're talking about? Why can't I just get the export and print functions in the right-click context menu like I see in all your sample charts (like this)?

SAI_SaveAsImage.jpg

Share this post


Link to post
Share on other sites

If this will help, here's the code portion of the application that I'm creating that deals with the chart creation. You'll note that I'm allowing the user to dynamically enter the data. What do I need to do to it to make "Print" and "Export" work with the right-click context menu (like the image I showed in my previous reply)?

Ideally, I'd really like to provide Print and Export to my user via a button (and not the right-click context menu) to begin with ... but, I'll settle for the context menu approach if you can steer me there.

#include "com/fusioncharts/includes/LoadingFunctions.as"

#include "com/fusioncharts/includes/AppMessages.as"

//To create the chart, you now need to import the Class of the

//chart which you want to create. All charts are present in the package

//com.fusioncharts.core.charts (Download Package > SourceCode folder)

//If you're using multiple charts, you can import all the requisite

//chart classes in the main timeline of your movie. That way, you

//wouldn't have to import the chart classes everytime you wish to use.

import com.fusioncharts.core.charts.Waterfall2DChart;

// -------------- Actual Code to create the chart ------------//

//To create a chart, you first need to create an empty movie clip to act as chart holder.

var chartContainerMC:MovieClip = this.createEmptyMovieClip("ChartHolder",5);

this.ChartHolder._x = 70;

this.ChartHolder._y = 15;

//Now, instantiate the chart using Constructor function of the chart.

var EVEchart:Waterfall2DChart = new Waterfall2DChart(chartContainerMC, 5, 880, 660, 10, 10, false, "EN", "noScale");

 

// function that refreshes all data on Chart Screen

function refreshData()

{

 var MainTitle:String = _root.UIpane.getContent().UI_MainTitle.getValue();

 var SubTitle:String = _root.UIpane.getContent().UI_SubTitle.getValue();

 var XAxisTitle:String = _root.UIpane.getContent().UI_XAxisTitle.getValue();

 var YAxisTitle:String = _root.UIpane.getContent().UI_YAxisTitle.getValue();

 var DataPrefix:String = _root.UIpane.getContent().UI_DataPrefix.getValue();

 var DataSuffix:String = _root.UIpane.getContent().UI_DataSuffix.getValue();

 var Data1Label:String = _root.UIpane.getContent().UI_Data1Label.getValue();

 var Data1Value:String = _root.UIpane.getContent().UI_Data1Value.getValue();

 var Data2Label:String = _root.UIpane.getContent().UI_Data2Label.getValue();

 var Data2Value:String = _root.UIpane.getContent().UI_Data2Value.getValue();

 var Data3Label:String = _root.UIpane.getContent().UI_Data3Label.getValue();

 var Data3Value:String = _root.UIpane.getContent().UI_Data3Value.getValue();

 var Data4Label:String = _root.UIpane.getContent().UI_Data4Label.getValue();

 var Data4Value:String = _root.UIpane.getContent().UI_Data4Value.getValue();

 var Data5Label:String = _root.UIpane.getContent().UI_Data5Label.getValue();

 var Data5Value:String = _root.UIpane.getContent().UI_Data5Value.getValue();

 var Data6Label:String = _root.UIpane.getContent().UI_Data6Label.getValue();

 var Data6Value:String = _root.UIpane.getContent().UI_Data6Value.getValue();

 var Data7Label:String = _root.UIpane.getContent().UI_Data7Label.getValue();

 var Data7Value:String = _root.UIpane.getContent().UI_Data7Value.getValue();

 var Data8Label:String = _root.UIpane.getContent().UI_Data8Label.getValue();

 var Data8Value:String = _root.UIpane.getContent().UI_Data8Value.getValue();

 var Data9Label:String = _root.UIpane.getContent().UI_Data9Label.getValue();

 var Data9Value:String = _root.UIpane.getContent().UI_Data9Value.getValue();

 var Data10Label:String = _root.UIpane.getContent().UI_Data10Label.getValue();

 var Data10Value:String = _root.UIpane.getContent().UI_Data10Value.getValue();

 

 

 // ------------- XML Data for the chart -------------- //

 

 //Generate the XML data. We hide the border of chart, set background

 //alpha as 0 (for transparency) and then set palette to 2.

 

 //strXML = strXML + "<vLine color='FF5904' thickness='2' />";

 //strXML = strXML + "<set label='Total Offering Economic Value' isSum='1' />";

 

 

 chartOpenTag = "<chart ";

 chartLabels = "caption='" + MainTitle + "' subcaption='" + SubTitle + "' xAxisName='" + XAxisTitle +

"' yAxisName='" + YAxisTitle + "' numberPrefix='" + DataPrefix + "' numberSuffix='" + DataSuffix + "' showValues='1' connectorDashed='1'" +

" showSumAtEnd='1' plotGradientColor='' showShadow='1' exportEnabled='1' imageSave='1'>";

 

 setData1 = "<set label='" + Data1Label + "' value='" + Data1Value + "' color='" + Data1Color + "' />";

 setData2 = "<set label='" + Data2Label + "' value='" + Data2Value + "' color='" + Data2Color + "' />";

 setData3 = "<set label='" + Data3Label + "' value='" + Data3Value + "' color='" + Data3Color + "' />";

 setData4 = "<set label='" + Data4Label + "' value='" + Data4Value + "' color='" + Data4Color + "' />";

 setData5 = "<set label='" + Data5Label + "' value='" + Data5Value + "' color='" + Data5Color + "' />";

 setData6 = "<set label='" + Data6Label + "' value='" + Data6Value + "' color='" + Data6Color + "' />";

 setData7 = "<set label='" + Data7Label + "' value='" + Data7Value + "' color='" + Data7Color + "' />";

 setData8 = "<set label='" + Data8Label + "' value='" + Data8Value + "' color='" + Data8Color + "' />";

 setData9 = "<set label='" + Data9Label + "' value='" + Data9Value + "' color='" + Data9Color + "' />";

 setData10 = "<set label='" + Data10Label + "' value='" + Data10Value + "' color='" + Data10Color + "' />";

 

 stylesOpenTag = "<styles>";

 stylesDef1 = "<definition>" +

 "<style name='CaptionFont' type='font' bold='1' face='Tahoma' size='18'/>" +

 "<style name='SubCaptionFont' type='font' bold='0' face='Tahoma' size='14'/>" +

"</definition>";

 stylesApp1 = "<application>" +

 "<apply toObject='caption' styles='CaptionFont' />" +

 "<apply toObject='subcaption' styles='SubCaptionFont' />" +

"</application>";

 stylesCloseTag = "</styles>";

 chartCloseTag = "</chart>";

 

 

 var strXML:String = chartOpenTag + chartLabels;

 //strXML += setData1;

 

 if (_root.UIpane.getContent().UI_Data1Value.field.length > 0){strXML += setData1;}

 if (_root.UIpane.getContent().UI_Data2Value.field.length > 0){strXML += setData2;}

 if (_root.UIpane.getContent().UI_Data3Value.field.length > 0){strXML += setData3;}

 if (_root.UIpane.getContent().UI_Data4Value.field.length > 0){strXML += setData4;}

 if (_root.UIpane.getContent().UI_Data5Value.field.length > 0){strXML += setData5;}

 if (_root.UIpane.getContent().UI_Data6Value.field.length > 0){strXML += setData6;}

 if (_root.UIpane.getContent().UI_Data7Value.field.length > 0){strXML += setData7;}

 if (_root.UIpane.getContent().UI_Data8Value.field.length > 0){strXML += setData8;}

 if (_root.UIpane.getContent().UI_Data9Value.field.length > 0){strXML += setData9;}

 if (_root.UIpane.getContent().UI_Data10Value.field.length > 0){strXML += setData10;}

 

 

 strXML += stylesOpenTag;

 strXML += stylesDef1;

 strXML += stylesApp1;

 strXML += stylesCloseTag;

 strXML += chartCloseTag;

 

 

 

 

 //FusionCharts chart classes accept XML data as XML Object

 //and not XML String.

 //So, if you've an XML string, first create an XML object from it

 //and then pass to the chart.

 var xmlData:XML = new XML(strXML);

 // --------------------------------------------------- //

 

 //Convey the XML data to chart.

 EVEchart.setXMLData(xmlData);

 

 //Show the chart container.

 chartContainerMC._visible = true;

 

 //Draw the chart

 EVEchart.render();

 

}

Share this post


Link to post
Share on other sites

Hi,

You are building AS2 application where this is not possible. You need to create AS3 application.

Please note that

1. The export feature (in standalone flash application) will ONLY work if you are having FusionCharts for FLEX swf files. These are different from normal FusionCharts SWF files.

2. You need to use FlashInterface http://flashextensions.com/products/flashinterface.php to connect to this Flex-dedicated SWF fies from your AS3 Application.

These are the primary things that you need to do...before following the instructions that i have provided in the previsous post.

Share this post


Link to post
Share on other sites

Thank you for your response, Sudipto, and your explanation. I am afraid that the limitations you outline are a "showstopper" for me. For a whole host of reasons (none the least, that I am using a significant number of AS2 3rd party components to achieve the requirements of my customer's application) I cannot use AS3, Flex, etc.

To be honest with you, I am both disapointed and a bit angry. I feel somewhat misled by the fact that your advertising of Fusion Charts never mentions any such limitations as you describe in your response anywhere that I can find. Everything I read on your web site implies that the full functionality of the product features is available to "Flash Developers who are looking to embed charts in their Flash movies" (your website's exact wording). Your explanation now makes it clear that this is not true, unless, of course, one wants to conform their design world to all the changes that would have to be made to accomodate what Fusion Charts will "really" do vs. what is advertised.

While I will gain some degree of benefit from using Fusion Charts in future projects for my customers, it's now clear that it will not come close to what I initially thought I would be able to achieve with it. In my mind, that certainly does not make it worth the amount of money ($499 USD) that I paid for it.

I do appreciate the responsiveness of you, your team and this forum. It's one of the better managed forums I've seen. However, I would be less than honest if I didn't say that I feel let down by your product claims which have "taken all the air out of my balloon" and the grandiose visions I had of what I would be able to do for my customers.

Respectfully,

... Don

Share this post


Link to post
Share on other sites

Hi Don,

 

 

 

First up, thanks for sharing your concerns with us. I would like to share some information with you, so as to throw light on why it's not possible.

 

 

 

In ActionScript 2 (Flash 8), Adobe doesn't provide the functionality to handle byte stream manipulation or even File references. So, technically its NOT possible to have any image saving algorithms in Flash 8 [without any server side scripts]. And we do provide server side scripts along with our components if you need to use in Flash 8. However, owing to Flash technology itself, you cannot save as image in Flash 8.

 

 

 

In Flash 9/10 [ActionScript 3.0] Adobe introduced Byte array and File reference class, which we've used to allow saving of images.

 

 

 

However, the charts will render in your Flash 8/9/10 apps.

 

 

 

I hope I've been able to clarify our stand on why we cannot really provide this. If you, however, still feel that FusionCharts is not worth the money you paid for, we would refund it unconditionally. For that, please drop us an email at support [at] fusioncharts.com with your order Id.

Share this post


Link to post
Share on other sites

Pallav,

Thank you for your response and explanation. I do appreciate your responsiveness and candor. As well, I do understand the points you make. If you would please, allow me in return to explain my end of it and then I believe we can move on to bigger and better things.

I took on a project recently from a first-time client that had requirements for dynamically creating Waterfall charts and subsequently printing, saving, and emailing the results. The success and on-time delivery of this project was critical to my hopes of establishing a long-term relationship with this customer. I purposely "low-balled" the contract price to show my "good faith" to win their business. The amount that I paid for your product consumed 25% of the margin I'm receiving for the job. I was willing to sacrifice this because of the importance to me to gain a new customer of this caliber. The job is due today (Monday). Specific requirements of the job dictated that I use AS2. I had no choice on that. My entire point to you was that had I known that your product would not have done the job, I probably would have continued to look elsewhere for a solution. But the limitations you mention in your response are nowhere to be found in your website or in any of your marketing or advertising. Why don't you just state those things up front rather than risk upsetting a new customer? Finding those out at the 11th hour has put me in a real bind. In this terrible economy we're all suffering from, I could absolutely not afford to lose the opportunity to secure this new customer.

As it turns out, I spent the whole weekend coming up with a solution where I use Fusion Charts to create the Waterfall chart itself and then MDM ZINC (which works marvelously with standalone Flash applications) to provide the "save image, print and email" functionality I needed. It looks promising for me delivering the end result to my customer as I had committed to today.

Your offer of returning my money is a very gracious and sincere move on your part. It certainly speaks to the fact that you wish to have satisfied customers. Since I have gone ahead and employed Fusion Charts in my project for the limited benefit it does provide in this particular application, I cannot in good faith accept your offer and take my money back. Morally and ethically, a deal is a deal is a deal ... and my usage of your product, to whatever degree, seals that and keeps my conscience clear.

Your product has many nice features and I'm sure that I will use it again sometime in the future for some other customer need of mine. Now that I know it's limitations with regards to Flash standalone applications, I will obviously make the necessary attempts in those cases to swing things towards AS3 from the get-go. In the long run, I'm fairly certain that I will eventually "get my money's worth" because I do think that somewhere, at some time, your product will provide a solution to my needs ... it just sure didn't happen that way this time around.

Again, my thanks for the dialogue your team has afforded on this matter. I'm sure you'll probably see me on the forum here somewhere down the road.

... Don

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello Don :),

 

 

 

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
Guest Angie

Dear User,

 

We are delighted to announce that PowerCharts is now ready for your iPads and iPhones too. We have just released PowerCharts v3.2. Starting v3.2, PowerCharts has HighCharts embedded within it, and offers both Flash and JavaScript (HTML5) charting . The Flash charts are displayed on a majority of devices and the JavaScript charts on devices that do not support Flash, all of it without writing a line of code.

 

Automatic rendering of JavaScript charts on devices (like iPad and iPhone) where Flash player is not supported.

 

5 new chart types:

 

Heat Map Chart

 

Box and Whisker Chart

 

Step Line Chart

 

Error Line Chart

 

Error Scatter Chart

 

 

* Support for JSON data format.

 

* Support for LinkedCharts, where a single data source controls multiple charts.

 

* Interactive legends in charts allow selective showing/hiding of data series.

 

* Legends now support icons for each data series.

 

* Better management of labels on charts.

 

* Labels now have an auto rendering mode to prevent them from overlapping, the chart selects the best display mode depending on the length of the labels and the width of the chart.

 

* Long labels are truncated, with ellipses appended to the truncated end of each label, and a tooltip bearing the completed label text is displayed when the user hovers over a truncated label.

 

* Support for line breaks and wrapping in all text elements including: caption, sub caption, X-axis title, Y-axis title, Labels and tooltips.

 

* In Line charts, data values can now be positioned either above or below the dataplots. Automatic positioning of data values is also supported.

 

* In Step-line charts dataplots can be joined using vertical lines.

 

* Custom alignment of caption and sub caption using STYLES.

 

* Advanced print management using JavaScript.

 

* Additional options for efficient event handling using JavaScript.

 

* Support for dynamic update of chart properties using JavaScript(barring select scatter and drag charts).

 

* Charts now support % based sizes along with dynamic resizing (barring select scatter and drag charts).

 

 

Learn more about everything new in PowerCharts v3.2 at : http:/ www.fusioncharts.com/PowerCharts/

 

We would love to hear from you at: http://www.fusioncharts.com/contact/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this