function swfLoadedCallback()
{
// Note... if these were a real application, you would want
// to use a setTimeout here to avoid Flash choking while
// waiting for a response.
alert('SWF loaded. Do something.');
}
然后,在 SWF 中添加如下代码:
import flash.external.ExternalInterface;
import flash.utils.setTimeout;
var params:Object = root.loaderInfo.parameters;
if (params && params.loadedCallback)
{
// Set timeout to avoid syncronous issues
setTimeout(function():void {
if (ExternalInterface.available)
ExternalInterface.call(params.loadedCallback);
}, 1);
}
Not directly, but it's easy to do if you have control over the SWF via ExternalInterface. First, in the flashvars for the SWF pass a callback name:
loadedCallback=swfLoadedCallback
Additionally, be sure the SWF has scriptAccess set to sameDomain or all
Next, Define a callback function in your page:
function swfLoadedCallback()
{
// Note... if these were a real application, you would want
// to use a setTimeout here to avoid Flash choking while
// waiting for a response.
alert('SWF loaded. Do something.');
}
Then, in your SWF, add code like this:
import flash.external.ExternalInterface;
import flash.utils.setTimeout;
var params:Object = root.loaderInfo.parameters;
if (params && params.loadedCallback)
{
// Set timeout to avoid syncronous issues
setTimeout(function():void {
if (ExternalInterface.available)
ExternalInterface.call(params.loadedCallback);
}, 1);
}
发布评论
评论(1)
不能直接实现,但如果您可以通过
ExternalInterface
控制 SWF,则很容易做到。首先,在 SWF 的 flashvar 中传递回调名称:loadedCallback=swfLoadedCallback
此外,请确保 SWF 将
scriptAccess
设置为sameDomain
或 < code>all接下来,在页面中定义回调函数:
然后,在 SWF 中添加如下代码:
Not directly, but it's easy to do if you have control over the SWF via
ExternalInterface
. First, in the flashvars for the SWF pass a callback name:loadedCallback=swfLoadedCallback
Additionally, be sure the SWF has
scriptAccess
set tosameDomain
orall
Next, Define a callback function in your page:
Then, in your SWF, add code like this: