2011-11-30 23 views
1

jQuery工具包含一個flashembed API接受許多參數。是否有一個接受回調函數並在Flash Player加載事件成功之後觸發?從jquery工具flashembed回調工具

playerdiv.flashembed(url+'/VIPlayer.swf','knds_player',300,250,'8.0.0',false,flashVars);

信息:official website

注:這是可能的Google swfobject library如下:

swfobject.embedSWF(url+'/VIPlayer.swf','knds_player',300,250,'8.0.0',false,flashVars,callBack);

function callBack(event){ event after successful display of code
}

但我只需要使用flashembed。你能幫我嗎?

感謝提前:)

回答

0

的flashembed方法有一個onFail的參數,它採用了回調的值:

$("#flash").flashembed({ 
    src: flashSWF, 
    version:[10,0], 
    id:"flashObj", 
    width: 500, 
    height: 300, 
    wmode: "opaque", 
    cachebusting: "false", 
    allowscriptaccess: "always", 
    api: "false", 
    scale: "noscale", 
    menu: "false", 
    onFail: flasherror("#flash") 
    }) 

它在不經意間觸發的成功和失敗。搜索,字符以區分這兩個狀態。在錯誤時,它顯示爲版本字符串分隔符,如11,0而非11.0

function flashError(domnode, newtext){ 

function failState() 
    { 
    if ($(domnode).html().search(/,/) !== -1) //player failed to load 
    { 
    newtext = $(domnode).html(); // store default error string 
    $(domnode).empty(); 
    $(domnode).append(newtext.replace(/,/g,".")); // replace comma with period 
    if ($(domnode).hasClass("flashmsg") === false) 
     { 
     $(domnode).addClass("flashmsg"); // add class to custom error element 
     } 
    } 
    else 
    { 
    //success logic 
    }   
} 

// observer constructor 
var cursor = 
typeof window.hasOwnProperty === "function" ? 
    window.hasOwnProperty("WebKitMutationObserver") 
    ? new WebKitMutationObserver(startValidation) 
    : window.hasOwnProperty("MutationObserver") 
     ? new MutationObserver(startValidation) 
     : false 
     : false 
    ; 

//Use observer event if it exists 
if (cursor)  
    { 
    //Bind observer event to text child of the dom node 
    cursor.observe($(domnode).get(0), { childList: true }); 
    return; 
    } 
//Use mutation event as a fallback 
else if (!!document.addEventListener) 
    { 
    $(domnode).get(0).addEventListener("DOMNodeInserted", failState, false); 
    } 
//Use readystatechange event for legacy IE 
else 
    { 
    $(domnode).get(0).addBehavior("foo.htc"); 
    $(domnode).get(0).attachEvent("onreadystatechange", failState); 
    } 

參考