某位天才能帮助解决这个问题吗!我们会非常感激的
实际上,我通过名为config.xml的配置文件加载了快闪音乐播放器。
Flash操作脚本示例
**myUltimateMp3Player.loadConfig("config.xml");**
import flash.external.ExternalInterface;
stop();
// ExternalInterface receive
if (ExternalInterface.available) {
ExternalInterface.addCallback("sendTextFromHtml", null, function(val:String):Void {
myUltimateMp3Player.loadConfig(val); });
}我尝试使用Swf对象动态嵌入闪存,因此当从html的列表中处理一个单击事件时,应该将相应的config.xml加载到闪存播放器上。
示例HTML代码:
$( document ).on( "click", "#Musiclist li", function() {
var c = "youtube-playlist";
$("#media-" + c).remove();
createMedia(c);
var id=this.id;
var idxml=id+".xml";
var swfPanel="media-" + c;
var flashvars = {};
var params = {};
params.swliveconnect = "true";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
var attributes = {};
attributes.id = "flashobj";
attributes.name = "flashobj";
swfobject.embedSWF("source.swf", "flashcontent", "100%", "100%", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes,callbackFn);
});回调函数
//This function is invoked by SWFObject once the <object> has been created
var callbackFn = function (e){
//Only execute if SWFObject embed was successful
if(!e.success || !e.ref){ return false; }
swfLoadEvent(function(){
var obj=e.ref;
obj.sendTextFromHtml("config.xml");
alert("The SWF has finished loading!");
});
};函数来保存SWF的PercentLoaded值的计时器,并等待直到它点击"100"
function swfLoadEvent(fn){
//Ensure fn is a valid function
if(typeof fn !== "function"){ return false; }
//This timeout ensures we don't try to access PercentLoaded too soon
var initialTimeout = setTimeout(function (){
//Ensure Flash Player's PercentLoaded method is available and returns a value
if(typeof e.ref.PercentLoaded !== "undefined" && e.ref.PercentLoaded()){
//Set up a timer to periodically check value of PercentLoaded
var loadCheckInterval = setInterval(function (){
//Once value == 100 (fully loaded) we can do whatever we want
if(e.ref.PercentLoaded() === 100){
//Execute function
fn();
//Clear timer
clearInterval(loadCheckInterval);
}
}, 1500);
}
}, 200);}所以我想不出我做错了什么,
错误是,
未定义未定义的ReferenceError: e
如果我不使用swfLoadEvent计时器,
错误是,
未明的TypeError:对象#没有方法'sendTextFromHtml‘
发布于 2013-11-07 16:31:45
e不是全局变量。尝试修改swfLoadEvent函数,将对swf的引用作为参数传递:
function swfLoadEvent(swf, fn){
swf.sendTextFromHtml("config.xml");
...
}然后被调用为
swfLoadEvent(e.ref, function(){
...
});https://stackoverflow.com/questions/19820009
复制相似问题