首頁  >  文章  >  web前端  >  页面调用单个swf文件,嵌套出多个方法。_javascript技巧

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

WBOY
WBOY原創
2016-05-16 17:59:121024瀏覽

HTML 端:
PART 1:

复制代码 代码如下:

{{foreach from=$question.question_item item="it" name="question_item"}}

{{$it.item_id}}
{{$it.item_name}}
9


{{/foreach}}

PART 2:
复制代码 代码如下:





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{
aryMSG.push(ary[j].value);
}
var arySWF = $(".swfarea");
for(i = 0; i {
var swfheight = $(".swfQuesCount")[i].value * 18 + 3;
createSWF(arySWF[i].id.toString(),swfheight.toString());
}
}

FLEX 端:
复制代码 代码如下:


layout="absolute" backgroundColor="0xffffff"
verticalScrollPolicy="off" horizontalScrollPolicy="off"
creationComplete="application1_creationCompleteHandler(event)">

<script> <br>import com.flexlib.moudel.statistical.StatisticalService; <br>import com.flexlib.moudel.statistical.StatisticalBar; <br>import com.flexlib.moudel.statistical.StatisticalPane; <br>import mx.events.FlexEvent; <br>private var res:StatisticalService = new StatisticalService(); <br>public function StatisticalManager(ary:Array):void <br>{ <br>var bar:StatisticalBar = new StatisticalBar(); <br>bar.width = 350; <br>bar.height = 15; <br>bar.accurate = 1; <br>// bar.color = 0x9999ff; <br>var pane:StatisticalPane = new StatisticalPane(); <br>pane.width = 520; <br>pane.height = 15; <br>pane.titleSpace = 50; <br>pane.voteSpace = 35; <br>pane.barSpace = 25; <br>pane.percentSpace = 60; <br>res.dataArray = ary; <br>res.autoColorEnabled =true; <br>res.geostrophyEnabled = true; <br>res.geostrophy = [0xffffff,0xcccccc]; <br>res.StatisticalList(pane,bar,cvs); <br>} <br>protected function application1_creationCompleteHandler(event:FlexEvent):void <br>{ <br>var item:Object = Application.application.parameters; <br>var aryMSG:Object = ExternalInterface.call("resultArray"); <br>var strtmp:String; <br>var newAry:Array = new Array(); <br>for(var i:int = 0; i { <br>strtmp = aryMSG[i].substring(aryMSG[i].indexOf("singleId:") + 9,aryMSG[i].length - 1); <br>if(strtmp == item.quesID){ newAry.push(aryMSG[i]); } <br>} <br>StatisticalManager(newAry); <br>} <br>]]> <br></script>

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn