HTML:
PART 1:
Copy codeThe Code is as follows: {foreach from = $ question. question_item item = "it" name = "question_item "}}
<Tr>
<Td align = "left" >{{$ it. item_id }}</td>
<Td align = "left" >{{$ it. item_name }}</td>
<Td align = "left"> 9
<Input type = "hidden" class = "swfhdn" value = "{title :{{$ it. item_name }}, vote: 12 votes, proportion: 0.25, singleId: swfdv {{{$ key + 1 }}"/> </td>
</Tr>
{{/ Foreach }}
PART 2:Copy codeThe Code is as follows: <div style = "width: pixel PX; height: 10px; background-color: # FFF; float: left;"> </div>
<Div id = "swfdv {$ key + 1}" class = "swfarea"> </div>
<Input type = "hidden" class = "swfQuesCount" value = "{$ key + 10}"/>
JS file:Copy codeThe Code is as follows: function createSWF (swfHome, swfHeight)
{
If (swfobject. hasFlashPlayerVersion ("9 "))
{
Var flashvars = {};
Flashvars. quesID = swfHome;
Swfobject. embedSWF ("swf/statistic2.swf", swfHome, "520", swfHeight, "9", "", flashvars );
}
}
Var aryMSG = new Array ();
Function resultArray () {return aryMSG ;}
Function init ()
{
Var ary = $ (". swfhdn ");
For (j = 0; j <ary. length; j ++)
{
AryMSG. push (ary [j]. value );
}
Var arySWF = $ (". swfarea ");
For (I = 0; I <arySWF. length; I ++)
{
Var swfheight = $ (". swfQuesCount") [I]. value * 18 + 3;
CreateSWF (arySWF [I]. id. toString (), swfheight. toString ());
}
}
FLEX end:Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: mx = "http://www.adobe.com/2006/mxml"
Layout = "absolute" backgroundColor = "0 xffffff"
VerticalScrollPolicy = "off" horizontalScrollPolicy = "off"
CreationComplete = "application1_1_creationcompletehandler (event)">
<Mx: VBox id = "cvs" y = "2" width = "100%" height = "100%" verticalGap = "5"/>
<Mx: Script>
<! [CDATA [
Import com. flexlib. moudel. statistical. StatisticalService;
Import com. flexlib. moudel. statistical. StatisticalBar;
Import com. flexlib. moudel. statistical. StatisticalPane;
Import mx. events. FlexEvent;
Private var res: StatisticalService = new StatisticalService ();
Public function StatisticalManager (ary: Array): void
{
Var bar: StatisticalBar = new StatisticalBar ();
Bar. width = 350;
Bar. height = 15;
Bar. accurate = 1;
// Bar. color = 0x9999ff;
Var pane: StatisticalPane = new StatisticalPane ();
Pane. width = 520;
Pane. height = 15;
Pane. titleSpace = 50;
Pane. voteSpace = 35;
Pane. barSpace = 25;
Pane. percentSpace = 60;
Res. dataArray = ary;
Res. autoColorEnabled = true;
Res. geostrophyEnabled = true;
Res. geostrophy = [0 xffffff, 0 xcccccc];
Res. StatisticalList (pane, bar, cvs );
}
Protected function application1_creationCompleteHandler (event: FlexEvent): void
{
Var item: Object = Application. application. parameters;
Var aryMSG: Object = ExternalInterface. call ("resultArray ");
Var strtmp: String;
Var newAry: Array = new Array ();
For (var I: int = 0; I <aryMSG. length; I ++)
{
Strtmp = aryMSG [I]. substring (aryMSG [I]. indexOf ("singleId:") + 9, aryMSG [I]. length-1 );
If (strtmp = item. quesID) {newAry. push (aryMSG [I]);}
}
StatisticalManager (newAry );
}
]>
</Mx: Script>
</Mx: Application>