页面调用单个swf文件,嵌套出多个方法。_javascript技巧
程序员文章站
2022-05-17 10:29:27
...
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)">
PART 1:
复制代码 代码如下:
{{foreach from=$question.question_item item="it" name="question_item"}}
{{/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 端:
复制代码 代码如下:
verticalScrollPolicy="off" horizontalScrollPolicy="off"
creationComplete="application1_creationCompleteHandler(event)">