First step:
Jsp:1
Copy Code code as follows:
<% @page import= "Java.util.random,java.util.gregoriancalendar"%>
<?xml version= "1.0" encoding= "Utf-8"?>
<items>
<%
GregorianCalendar calendar = new GregorianCalendar ();
int year = Calendar.get (calendar. year);
int month = Calendar.get (calendar. MONTH) + 1;
int today = Calendar.get (Calendar. Day_of_month);
String strday=year+ "," +month+ "," +today+ ",";
int SB = 400;
string[] dates = new string[] {strday+ "14,60"};
String Crutime=request.getparameter ("Time");
Crutime=crutime.replace (":", ",");
if (crutime!=null) {
Crutime=crutime.replace (":", ",");
dates = new string[] {strday+crutime};
}
for (int i = 0; i < dates.length; i++) {
Random Random = new Random ();
int r = random.nextint (1000);
%>
<item> <value>
<%
if (I < 10) {
%><%=r%>
<%
}
%>
</value> <date><%=dates[i]%></date> <sb><%=sb%></sb> </item>
<%
}
%>
</items>
Jsp:2
Copy Code code as follows:
<%@ page language= "java" import= "java.util.*" pageencoding= "gb2312"%>
<%
String path = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () + Request.getcontextpath ();
%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache" >
<meta http-equiv= "Expires" content= "0" >
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >
<meta http-equiv= "description" content= "This are my page" >
<script language= "Jscript.encode" src= "Js/swfobject.js" type= "Text/javascript" ></SCRIPT>
<body topmargin= "0" leftmargin= "0" >
<div align= "center" style= "MARGIN-TOP:40;" >
<div id= "flashcontent" width= "height=" align= "center" ></div>
<script type= "Text/javascript" >
var so = new SWFObject ("<%=path%>/testfrist.swf", "Main", "the" "," "" "," 9.0 "," #ffffff "," high ");
So.addvariable ("Myamfurl", "<%=path%>/nxsy.jsp");
So.addvariable ("Myamtitle", "Bear win");
So.write ("Flashcontent");
</script>
</div>
</body>
Step Two Flex code:
Copy Code code as follows:
<mx:application xmlns:mx= "Http://www.adobe.com/2006/mxml" layout= "absolute" width= "100%" White "Creationcomplete=" Init (); >
<mx:Style>
. font12{font-family: Song body; fontsize:15}
. lenchar{
bar-color:red;
}
. mypaneltitle {
Color: #66ccff;
Fontfamily:comic Sans MS;
Fontweight:normal;
Textdecoration:underline;
}
</mx:Style>
<mx:script><! [cdata[
Import Flash.sampler.getMemberNames;
Import Mx.charts.chartClasses.IAxis;
Import Mx.charts.LinearAxis;
Import Mx.charts.HitData;
Import mx.collections.ArrayCollection;
Import mx.rpc.events.ResultEvent;
Import Mx.controls.Alert;
Import Mx.charts.renderers.CircleItemRenderer;
Import Mx.graphics.Stroke;
Import Mx.controls.DateField;
[bindable]
private var myamfurl:string = ""; Used to connect to an external page
[bindable]
private var myamtitle:string = ""; Used to connect to an external page
[bindable]
public var testdatas:arraycollection=new arraycollection ();
[bindable]
private var expenses:arraycollection = new ArrayCollection ();
[bindable]
private var Arr:array = new Array ();
[bindable]
private Var mintime:date;
[bindable]
private Var maxtime:date;
[bindable]
private Var smintime:date;
[bindable]
private Var emaxtime:date;
private Var Timer:timer;
private Var Stocksb:number;
private Var datevar:date;
private var d:date = new Date ();
Private Function init (): void{
SetInterval (torequest,2000);
Myamfurl = Application.application.parameters.myAmfurl; Risk Traceability Link
Myamtitle=application.application.parameters.myamtitle;
Timer = new timer (1000);
Timer.addeventlistener (Timerevent.timer, Torequest)
Timer.start ();
}
Public Function Torequest (et:event): void{
SetStyle ();
Realtimeservice.send ();
}
Used to set styles
Public Function SetStyle (): void{
}
Private Function Formatdatatip (hitdata:hitdata): String
{
var s:string = hitData.item.date.toString ();
var A:array = S.split (",");
var str:string=a[3]+ ":" +a[4];
str + = "\ n";
str = HitData.item.value;
return str;
}
Private Function Parsedate (value:string):D ate{
var A:array = Value.split (",");
var newdate:date = new Date (a[0],a[1],a[2],a[3],a[4]);
return newdate;
}
Private Function GetResult (e:resultevent): void{
var min:string= "";
var pattern:regexp=/,/gi;
For each (Var resultxml:xml in E.result.item) {
var tmpobj:object=new Object ();
Tmpobj.value=resultxml.value;
Tmpobj.date=resultxml.date;
TMPOBJ.SB=RESULTXML.SB;
Stocksb=number (TMPOBJ.SB);
var str=tmpobj.date;
var A:array = Str.split (",");
Mintime= new Date (a[0],a[1],a[2],9,30);
Smintime= new Date (a[0],a[1],a[2],11,30);
Min=tmpobj.date;
Maxtime=new Date (a[0],a[1],a[2],15,00);
Emaxtime=new Date (a[0],a[1],a[2],13,00);
if (expenses.length==0) {
Expenses.additem (Tmpobj);
}else{
var check:int=0;
if (expenses.length>0) {
For each (var subtempobj:object in expenses) {
if (String (subtempobj.date). Replace (Pattern, "") ==string (tmpobj.date). Replace (Pattern, "")) {
check=1;
}
}
}
if (check==0) {
Expenses.additem (Tmpobj);
check=0;
}
}
}
var tmpobj1:object=new Object ();
var tmpobj2:object=new Object ();
var A:array = Min.split (",");
TMPOBJ1.VALUE=STOCKSB;
Tmpobj1.date=a[0]+ "," +a[1]+ "," +a[2]+ "," + "9,30";
TMPOBJ2.VALUE=STOCKSB;
Tmpobj2.date=a[0]+ "," +a[1]+ "," +a[2]+ "," + "15,00";
Testdatas.additem (TMPOBJ1);
Testdatas.additem (TMPOBJ2);
}
Private Function MyLabel (Labelvalue:object, Previousvalue:object, D:iaxis): String {
var temp:string= "";
var currvalue:number = number (labelvalue.tostring ());
if (CURRVALUE>STOCKSB) {
temp = ' <font color= ' #ff0000 ' size= ' > ' +labelvalue.tostring () + ' </font> ';
}else{
temp = ' <font color= ' #48ff00 ' size= ' > ' +labelvalue.tostring () + ' </font> ';
}
return temp;
}
]]></mx:script>
<!--Define custom strokes. -->
<mx:stroke id = "S1" color= "#FFFFFF" weight= "0.1"/>
<mx:stroke id = "S2" color= "#F1F1B8" weight= "1"/>
<mx:stroke id = "S3" color= "Green" weight= "1"/>
<mx:stroke id= "Vstroke" color= "Red" weight= "1" alpha= "0.6"/>
<mx:httpservice result= "GetResult" (event); "Id=" Realtimeservice "url=" {myamfurl} "useproxy=" false "resultformat=" E4x "method=" POST ">
</mx:HTTPService>
<mx:panel title= "{myamtitle}" fontsize= "" height= "100%" width= "100%" color= "Red" backgroundcolor= "#000000" borderstyle= "Inset" >
<mx:linechart stylename= "Lenchar" datatipfunction= "Formatdatatip" showdatatips= "true" height= "100%" width= "100%" Id= "Chart" fontfamily= "Song Body" fontsize= ">"
<mx:backgroundElements>
<mx:gridlines direction= "both" >
<mx:horizontalStroke>
<mx:stroke color= "Red" weight= "1" alpha= "0.6"/>
</mx:horizontalStroke>
<mx:verticalStroke>
<mx:stroke color= "Red" weight= "1" alpha= "0.2"/>
</mx:verticalStroke>
</mx:GridLines>
</mx:backgroundelements >
<!--vertical axis-->
<mx:verticalAxis>
<mx:linearaxis id= "va" baseatzero= "false" title= "labelfunction=" MyLabel "/>"
</mx:verticalAxis>
<mx:horizontalAxis>
<!--mx:categoryaxis id= "Ca" categoryfield= "date" displayname= "date" title= "date"/-->
<!--mx:linearaxis displayname= "Date" minimum= "1" id= "Ca" interval= "ten"/-->
<!--<mx:datetimeaxis dataunits= "Seconds" interval= "minimum=" {mindate} "maximum=" {maxdate} "/>-->
<!--<mx:datetimeaxis id= "Haxis" parsefunction= "Parsedate" interval= "1" minimum= "{mintime}" maximum= "{maxtime}" "Displaylocaltime=" true "datainterval=" 1 "dataunits=" hours "labelunits=" hours "/>-->
<mx:datetimeaxis id= "Haxis"
Disableddays= ' {[0,6]} '
Disabledranges= ' {[{rangestart:smintime, rangeend:emaxtime}]} '
parsefunction= "Parsedate" interval= "1" minimum= "{mintime}" maximum= "{maxtime}" Displaylocaltime= "true" DataInterval = "dataunits=" "Minutes" labelunits= "minutes"
/>
</mx:horizontalAxis>
<!--horizontal axis renderer-->
<mx:horizontalAxisRenderers>
<mx:axisrenderer axis= "{haxis}" candroplabels= "true" axisstroke= "{Vstroke}"/>
</mx:horizontalAxisRenderers>
<mx:verticalAxisRenderers>
<mx:axisrenderer axis= "{va}" candroplabels= "true" axisstroke= "{Vstroke}"/>
</mx:verticalAxisRenderers>
<!--series-->
<mx:series>
<mx:lineseries id= "series" yfield= "Value" xfield= "date" displayname= "value" dataprovider= "{this.expenses}" Linestroke= "{s1}"/>
<mx:lineseries yfield= "value" xfield= "date" displayname= "TestData" dataprovider= "{This.testdatas}" linestroke= "{ S2} "/>
</mx:series>
</mx:LineChart>
</mx:Panel>
</mx:Application>