欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

flex下载 FlexFlashXML脚本 

程序员文章站 2024-02-29 08:42:10
...
xxxxxx.mxml内容


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
applicationComplete="effectEvaluaChartData();"
xmlns:companyname="com.companyname.bass.*"
xmlns:bi="com.companyname.bass.chart.series.*"
xmlns:dropdown="com.companyname.components.*"
paddingTop="0" paddingBottom="0" paddingLeft="0" paddingRight="0">
<mx:Style>  
    Application{   
        fontSize:12;       
        backgroundGradientColors: #D6E4F3, #D6E4F3;
        z-index:-1;
    }   
</mx:Style>
<!-- 脚本-->
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.effects.IAbstractEffect;
import mx.controls.Alert;
import mx.controls.CheckBox;
import mx.controls.ComboBox;
import mx.events.ItemClickEvent;
      import mx.controls.TabBar;
      import mx.charts.series.items.LineSeriesItem;
import mx.charts.events.ChartItemEvent;
import flash.external.ExternalInterface;
import mx.graphics.codec.JPEGEncoder;
import flash.display.BitmapData;
import mx.core.UIComponent;
//全局变量
private var skinOldPath:String;
//初始化方法
private function effectEvaluaChartData():void
{  
//初始化参数
var params: URLVariables = new URLVariables();
params.startDate = this.parameters.startDate;
params.endDate = this.parameters.endDate;
params.areaCode = this.parameters.areaCode;
params.optActId = this.parameters.optActId;
params.guidelineIdJ = this.parameters.guidelineIdJ;
//方法注册
ExternalInterface.addCallback("downExport", downExport);  //导出报表
}

//导出报告
private function downExport(startDate:String, endDate:String, areaCode:String, optActId:String, guidelineIdJ:String):void
{
var byteMD:BitmapData = bitmapDataToByteArray(effectEvaluaChart);
var en:JPEGEncoder = new JPEGEncoder(100);
var ba:ByteArray=en.encode(byteMD);
var request:URLRequest = new URLRequest("effectEvalua.do?action=downloadOptEffectEvaluaList&startDate="+startDate+"&endDate="+endDate+"&areaCode="+areaCode+"&optActId="+optActId+"&guidelineIdJ="+guidelineIdJ);
request.method = "POST";
request.data = ba;
request.contentType = "application/octet-stream";
navigateToURL(request, "_self");
}

//按像素读取控件
private function bitmapDataToByteArray(target : UIComponent):BitmapData
{
var imageWidth:uint = target.width;
var imageHeight:uint = target.height;
  var srcBmp:BitmapData = new BitmapData( imageWidth, imageHeight );
  srcBmp.draw(target);
  return srcBmp;
}

//用来加载结果集数据
private function loadComplete(event:LoaderEvent):void
{
effectEvaluaChart.xmlConstructor = event.result as XML;
effectEvaluaChart.colorSeries = event.colorSeriesArray;
effectEvaluaChart.tips = BIChart.TIPS_SHOW;
effectEvaluaChart.reload();
}

//用户点击该图形时调用
private function doClick(event:BIChartEvent):void{

//var lineChartItem:LineSeriesItem = LineSeriesItem(event.hitData.chartItem);
/* Alert.show(lineChartItem.xValue.toString());
Alert.show(lineChartItem.yFilter.toString()); */
trace(event.dimensionField);
}
]]>
</mx:Script>
<companyname:LineChart width="100%"  height="100%" id="effectEvaluaChart" fontSize="10"/>
</mx:Application>

xxxxxx.java