1
votes

I am embedding a flex swf inside a html/dojo popup dynamically. It works fine in FF and Chrome but in IE8/IE9 I am getting "TypeError: Object doesn't support this property or method". In IE the first time the popup with the swf is created everything works fine. However once I hide the popup and open it again and then try and call the actionscript function inside flex it throws error. Any help will be appreciated. Following is the code snippet:

var srchSuggestDlg;
var srchDlg;
var isSuggSwfInit = false;

/* Called on key up for the search box widget or when search arrow button is clicked
* Displays search suggestions inside popover below the search widget 
*/

cpm.home.index.searchKeyUp = function(evt) {

var srchInput = dojo.byId('xwt_widget_uishell_Header17_0_search_searchTextAP');

if(srchInput.value.length<3)
    return;

if(srchSuggestDlg && srchSuggestDlg.isShowingNow)
{
    try
    {
        swfobject.getObjectById("srchSuggSwf").updateSearchInFlex(srchInput.value);
    }
    catch(e){
        console.error("swf may not be ready 1",e);
    }
    return;
}

if(srchSuggestDlg == null)
{
    srchSuggestDlg = new xwt.widget.layout.Popover({pinnable: false, title: "Suggestions", sideAlign: false, autofocus: false, showHelp: false});
    var divx=dojo.create("div");
    divx.innerHTML="<div id='srchSuggDiv'></p></div>";
    srchSuggestDlg.containerNode.appendChild(divx);

    srchSuggestDlg.openAroundNode(srchInput);

    var flashvars = {swfId:"srchSuggSwf", searchString:srchInput.value};
    var params = {};
    params.quality = "high";
    params.bgcolor = "#ffffff";
    params.allowscriptaccess = "sameDomain";
    params.allowfullscreen = "true";
    var attributes = {};
    attributes.id = "srchSuggSwf";
    attributes.name = "srchSuggSwf";
    attributes.align = "middle";
    params.wmode="window";

    var cachecontrol = Math.floor(Math.random()*99999);

    swfobject.embedSWF("pages/modules/monitor/flex/SearchSuggestion.swf?"+cachecontrol,"srchSuggDiv","200","140","9.0.0","playerProductInstall.swf",flashvars, params, attributes);
    swfobject.createCSS("#srchSuggDiv", "display:block;text-align:left;");

}
else
{
    srchSuggestDlg.openAroundNode(srchInput);
    try
    {
        var srchInput1 = dojo.byId('xwt_widget_uishell_Header17_0_search_searchTextAP');
        //dojo.byId("srchSuggSwf").updateSearchInFlex(srchInput1.value);
        swfobject.getObjectById("srchSuggSwf").updateSearchInFlex(srchInput1.value);
    }
    catch(e) {
        console.error("swf may not be ready 2",e);
    }
}
};


/* Called from flex once flex swf is initialized 
*/

cpm.home.index.suggSwfInit = function(value){
var srchInput = dojo.byId('xwt_widget_uishell_Header17_0_search_searchTextAP');
try
{
    dojo.byId("srchSuggSwf").updateSearchInFlex(srchInput.value);
}
catch(e){
    console.error("swf may not be ready in 3",e);
}
};
1
I'm confused; are you receiving a Flex error or a JavaScript error? The code you've provided is JavaScript; correct?JeffryHouser
I believe you have to "reattach" the swf methods after you make the component visible again.Ja͢ck
@flextras.com : I am getting a javascript error "TypeError: Object doesn't support this property or method" on line "swfobject.getObjectById("srchSuggSwf").updateSearchInFlex(srchInput.value);". updateSearchInFlex is a actionscript function in my flex swf following is how I add listner in my flex code: flash.external.ExternalInterface.addCallback("updateSearchInFlex",updateList);rindshegs
@Jack: You mean I need to reattach listner/callback from flex swf once swf is visible again? How do I check from inside flex swf if its visible again? Right now I am using creation complete event to attach the listner which is fired only once when the swf is created the first time. Is it one of these: activate, show, updateComplete?rindshegs

1 Answers

-1
votes

Common issue, download and install Node.js = https://nodejs.org/en/download/