您的位置:首页 > Web前端 > JQuery

手把手教新手写jquery插件(转自www.jqueryba.com)

2012-08-24 20:35 471 查看
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)">
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<mx:SolidColor id="sc1" color="blue" alpha=".3"/>
<mx:SolidColor id="sc2" color="red" alpha=".3"/>
<mx:SolidColor id="sc3" color="green" alpha=".3"/>
<mx:SolidColorStroke id = "s1" color="blue" weight="2"/>
<mx:SolidColorStroke id = "s2" color="red" weight="2"/>
<mx:SolidColorStroke id = "s3" color="green" weight="2"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
private var dp:ArrayCollection = new ArrayCollection( [
{ Month: "Jan", Profit: 2000, Expenses: 1500, Amount: 450 },
{ Month: "Feb", Profit: 1000, Expenses: 200, Amount: 600 },
{ Month: "Mar", Profit: 1500, Expenses: 500, Amount: 300 },
{ Month: "Apr", Profit: 1800, Expenses: 1200, Amount: 900 },
{ Month: "May", Profit: 2400, Expenses: 575, Amount: 500 } ]);

private var timer:Timer = new Timer(2000);
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
timer.addEventListener(TimerEvent.TIMER,timerHander);
timer.start();
}

private function timerHander(event:TimerEvent):void{
for(var i:int=0; i < dp.length; i++){
dp[i].Profit= dp[i].Profit + int(Math.random()*100);
dp[i].Expenses= dp[i].Expenses + int(Math.random()*100);
dp[i].Amount= dp[i].Amount + int(Math.random()*100);
}

dp.refresh();
}

]]>
</fx:Script>
<mx:LineChart id="linechart1" width="600" height="400" dataProvider="{dp}" showDataTips="true">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Month" />
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries yField="Profit" form="curve" displayName="Profit" lineStroke="{s1}"/>
<mx:LineSeries yField="Expenses" form="curve" displayName="Expenses" lineStroke="{s2}"/>
<mx:LineSeries yField="Amount" form="curve" displayName="Amount" lineStroke="{s3}"/>
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider="{linechart1}"/>
</s:Application>

 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: