页面调用单个swf文件,嵌套出多个方法。

时间:2021-05-25

HTML 端:
PART 1:
复制代码 代码如下:
{{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票,proportion:0.25,singleId:swfdv{{$key+1}}}"/></td>
</tr>
{{/foreach}}

PART 2:
复制代码 代码如下:
<div style="width:190px; 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 文件:
复制代码 代码如下:
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 端:
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://pleteHandler(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>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章