Flex初探

最近在做一个工资统计模块,之前用了一个叫amchart
 的flash组件,感觉还是挺不错的,使用的效果如下,

后来又要实现一个明细的页面,心想已经用了flash技术了,干脆把flex技术也搞上,于是安装了flex builder,现学现用,

花了些时间, 做了个效果图,如下

 这里就只附上flex的代码,关于amchart,大家就自己google一下吧,

flex代码如下

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns="*" applicationComplete="send_data()">
    <mx:Script>
        <![CDATA[
        	import mx.rpc.events.ResultEvent;
        	import mx.rpc.http.HTTPService;
        	import mx.controls.Alert;
        	private var service:HTTPService=new HTTPService();
            private function send_data():void {
            	
				service.url="http://192.168.1.190/wage/services.php?month="+this.parameters.month+"&team="+encodeURI(this.parameters.team);
				service.useProxy=false;
				service.method="post";
				Alert.show(this.parameters.month+"  "+this.parameters.team+" "+service.url);
            	service.send();  
            }
        ]]>
    </mx:Script>
    <mx:DataGrid id="dataResult" dataProvider="{service.lastResult.wages.mem}" horizontalCenter="-38" verticalCenter="11" width="900" height="500">
        <mx:columns>
            <mx:DataGridColumn headerText="姓名" dataField="xm"/>
            <mx:DataGridColumn headerText="加班补贴" dataField="jbbt"/>
			<mx:DataGridColumn headerText="请假" dataField="qj"/>
            <mx:DataGridColumn headerText="扣款" dataField="kk"/>
            <mx:DataGridColumn headerText="住宿" dataField="sz"/>
            <mx:DataGridColumn headerText="满勤" dataField="mq"/>
            <mx:DataGridColumn headerText="社保" dataField="sb"/>
            <mx:DataGridColumn headerText="工龄" dataField="gl"/>
            <mx:DataGridColumn headerText="其他补贴" dataField="bt"/>
            <mx:DataGridColumn headerText="卡号" dataField="kh"/>
        </mx:columns>
    </mx:DataGrid>

</mx:Application>

 flex builder对应自动生成的html,为实现html传参,需做些修改,代码如下

<!-- saved from url=(0014)about:internet -->
<html lang="en">

<!-- 
Smart developers always View Source. 

This application was built using Adobe Flex, an open source framework
for building rich Internet applications that get delivered via the
Flash Player or to desktops via Adobe AIR. 

Learn more about Flex at http://flex.org 
// -->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--  BEGIN Browser History required section -->
<link rel="stylesheet" type="text/css" href="history/history.css" />
<!--  END Browser History required section -->

<title></title>
<script src="AC_OETags.js" language="javascript"></script>

<!--  BEGIN Browser History required section -->
<script src="history/history.js" language="javascript"></script>
<!--  END Browser History required section -->

<style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 124;
// -----------------------------------------------------------------------------
// -->

//注:这个是重点,用于实现html传参
function getparafromurl() {
var url,pos,parastr,para;
url = window.location.href;
pos = url.indexOf("?")
parastr = url.substring(pos+1);
return parastr;
}
</script>
</head>

<body scroll="no">
<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

if ( hasProductInstall && !hasRequestedVersion ) {
	// DO NOT MODIFY THE FOLLOWING FOUR LINES
	// Location visited after installation is complete if installation is required
	var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
	var MMredirectURL = window.location;
    document.title = document.title.slice(0, 47) + " - Flash Player Installation";
    var MMdoctitle = document.title;

	AC_FL_RunContent(
		"src", "playerProductInstall",
		"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
		"width", "100%",
		"height", "100%",
		"align", "middle",
		"id", "fourFlex",
		"quality", "high",
		"bgcolor", "#869ca7",
		"name", "fourFlex",
		"allowScriptAccess","sameDomain",
		"type", "application/x-shockwave-flash",
		"pluginspage", "http://www.adobe.com/go/getflashplayer",
		//为保证flex能接受到html参数,需加如下语句
		"FlashVars", getparafromurl()
	);
} else if (hasRequestedVersion) {
	// if we've detected an acceptable version
	// embed the Flash Content SWF when all tests are passed
	AC_FL_RunContent(
			"src", "fourFlex",
			"width", "100%",
			"height", "100%",
			"align", "middle",
			"id", "fourFlex",
			"quality", "high",
			"bgcolor", "#869ca7",
			"name", "fourFlex",
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer",
			//为保证flex能接受到html参数,需加如下语句
			"FlashVars", getparafromurl()
	);
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here. '
  	+ 'This content requires the Adobe Flash Player. '
   	+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
  }
// -->
</script>
<noscript>
  	<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fourFlex" width="100%" height="100%"
			codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
			<param name="movie" value="fourFlex.swf" />
			<param name="quality" value="high" />
			<param name="bgcolor" value="#869ca7" />
			<param name="allowScriptAccess" value="sameDomain" />
			<embed src="fourFlex.swf" quality="high" bgcolor="#869ca7"
				width="100%" height="100%" name="fourFlex" align="middle"
				play="true"
				loop="false"
				quality="high"
				allowScriptAccess="sameDomain"
				type="application/x-shockwave-flash"
				pluginspage="http://www.adobe.com/go/getflashplayer">
			</embed>
	</object>
</noscript>
</body>
</html>

 services.php:

require_once("db_class.php");
$db=new mysql("127.0.0.1","root","1234","wage","conn","utf8");
$month=$_REQUEST['month'];
$team_name=urldecode($_REQUEST['team']);

$sql="select xm,jbbt,qj,kk,sz,fk,mq,sb,gl,bt,kh,team from wage_detail where month=$month and team='$team_name'";


$arr=$db->fetchrows($sql);

$doc = new DOMDocument('1.0','utf-8');
$doc->formatOutput = true;
$r = $doc->createElement( "wages" );
$doc->appendChild( $r );

foreach( $arr as $user )
{
$mem = $doc->createElement( "mem" );

$xm = $doc->createElement( "xm" );
$xm->appendChild(
$doc->createTextNode( $user['xm'] )
);
$mem->appendChild( $xm );

$jbbt = $doc->createElement( "jbbt" );
$jbbt->appendChild(
$doc->createTextNode( $user['jbbt'] )
);
$mem->appendChild( $jbbt );

$qj= $doc->createElement( "qj" );
$qj->appendChild(
$doc->createTextNode( $user['qj'] )
);
$mem->appendChild( $qj );

$kk = $doc->createElement( "kk" );
$kk->appendChild(
$doc->createTextNode( $user['kk'] )
);
$mem->appendChild( $kk );

$sz = $doc->createElement( "sz" );
$sz->appendChild(
$doc->createTextNode( $user['sz'] )
);
$mem->appendChild( $sz );



$mq = $doc->createElement( "mq" );
$mq->appendChild(
$doc->createTextNode( $user['mq'] )
);
$mem->appendChild( $mq );

$sb = $doc->createElement( "sb" );
$sb->appendChild(
$doc->createTextNode( $user['sb'] )
);
$mem->appendChild( $sb );

$gl = $doc->createElement( "gl" );
$gl->appendChild(
$doc->createTextNode( $user['gl'] )
);
$mem->appendChild( $gl );

$bt = $doc->createElement( "bt" );
$bt->appendChild(
$doc->createTextNode( $user['bt'] )
);
$mem->appendChild( $bt );

$kh = $doc->createElement( "kh" );
$kh->appendChild(
$doc->createTextNode( $user['kh'] )
);
$mem->appendChild( $kh );

$r->appendChild( $mem );
}

echo $doc->saveXML();
?>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值