0
我有一個使用loadMovieNum(「flash.swf」,2)調用另一個AS2 Flash文件的AS2 Flash SWF以及使用定時器在頁面上調用函數的JavaScript文件。這是我在Firefox 10中使用Flash(IE8不給出錯誤信息):Flash和JavaScript通信問題
未捕獲的異常:在NPObject上調用 方法時出錯! [插件異常: Actionscript中的錯誤。使用try/catch 塊來查找錯誤。]。
怎麼回事?我看不到問題。這是假設以清除嵌入的SWF的內容,並使用一個Flash警告對話框,確認是或否
閃光燈:
import flash.external.ExternalInterface;
import mx.controls.Alert;
System.security.allowDomain("mydomain.com");
function getTimeOut()
{
// Show alert dialog box
_level2._visible = false;
Alert.show("You are about to Timeout. Do you want to continue using Courseware?", "Timeout", Alert.YES |
Alert.NO, this, myClickHandler);
}
ExternalInterface.addCallback("timeOut", this, getTimeOut);
this.onMouseDown = function(){
//if not on login
getURL("javascript:startTimer();");
};
var myClickHandler:Function = function (evt_obj:Object) {
switch (evt_obj.detail) {
case Alert.YES :
getURL("javascript:buttonEvent('yes');");
break;
case Alert.NO :
getURL("javascript:buttonEvent('no');");
break;
}
_level2._visible = true;
};
//load courseware
loadMovieNum("embedded.swf",2);
的JavaScript:
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("main.swf", "mainMovie", "100%", "100%", "9", "#083770");
so.addParam("scale", "noscale");
so.addParam("quality", "high");
so.addParam("allowScriptAccess","always");
so.write("flashcontent");
var timerMin = '<?php echo($timerMinutes); ?>';
var timer;
var timer2;
function startTimer()
{
var timerMill = 0;
clearTimeout(timer);
timerMill = getMillis();
timer = setTimeout ('stopTimer()', timerMill);
}
function stopTimer()
{
clearTimeout(timer);
timer2 = setTimeout('redirectPage()', 60000);
//call flash function
getFlashMovie("mainMovie").timeOut();
}
function buttonEvent(evt)
{
if(evt == 'yes')
{
clearTimeout(timer2);
startTimer();
}
else
{
clearTimeout(timer2);
redirectPage();
}
}
function getMillis()
{
var milliseconds = 300000;
if(timerMin == parseInt(timerMin))
{
//convert to milliseconds
//60000 milliseconds in 1 minute
milliseconds = (parseInt(timerMin)) * 60000;
}
return milliseconds;
}
function getFlashMovie(movieName)
{
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
//return document.getElementById(movieName);
}
function redirectPage()
{
top.location = "timeout.php?t=<?php echo($timerMinutes); ?>";
}
// ]]>
</script>