1

I need to change the swf embedded n my html page, when I click on a menuItem in the same page. I do not want to navigate to a new page with another swf because that will be a bit slower. So, I need some solutions. currently I am using div in the html to include a swf file in it. my current code is given below , the javascript method showAlert will be changed later , but this is the one I want to change the SWF file right now...

   <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
      <title>Wrapper Being Called</title>
       <script type="text/javascript" src="/TestProject/flashfiles/swfobject.js">       </script>
       <script type="text/javascript">
          var swfVersionStr = "0";
          var xiSwfUrlStr = "";
          var flashvars = {};
        var params = {};
        params.quality = "high";
        params.bgcolor = "#ffffff";
        params.allowscriptaccess = "always";
        var attributes = {};
        attributes.id = "WrapperCaller";
        attributes.name = "WrapperCaller";
        attributes.align = "middle";
        swfobject.embedSWF(
            "/TestProject/flashfiles/Project1.swf", "flashContent",
            "100%", "100%",
            swfVersionStr, xiSwfUrlStr,
            flashvars, params, attributes);
    </script>
</head>

 <SCRIPT LANGUAGE="JavaScript">
     function showAlert(a) {
        alert(a);
        return "successful";
     }

 </SCRIPT>

<body>
    <div id="flashContent"/>

5
  • 1
    So have you tried to figure out how to do it yourself? Or do you want someone here just to do it for you? Commented Mar 31, 2012 at 16:52
  • I have tried hard.... not working out. Tried to refresh the DIV contents through js not working. Also sent an email to the developers of the swfObject. but as of now no response. Commented Mar 31, 2012 at 17:20
  • shouldn't this also be tagged as an actionscript question? Commented Mar 31, 2012 at 17:38
  • No, this has nothing to do with actionscript, yes there is actionscript in the swf that I am trying to embed. but the only problem i am facing is in the javascript html side. Commented Mar 31, 2012 at 17:50
  • Depending on the number of SWF files you are dealing with here, I think your end result will be slow anyway. Option a) Have all your FLASH embedded on the page and then hide the ones you don't want to see with CSS (probably very slow) b) preload the SWF files using JavaScript (probably gonna be slow) and then change them depending on user action c) Use AJAX to get the SWF files on demand d) Use an IFRAME in your web page Commented Apr 1, 2012 at 2:01

1 Answer 1

1

Ok, I got the solution here, it's pretty simple and the speed is faster than putting the flash file in a separate page and navigating to it. All the swf files are on the server.

<body>
<table align="center" cellpadding="0"  cellspacing="0" border="0" >
    <tr align="center">
        <td align="center" >
            <div id="objectDIV" >   
                <object id="workingSWF" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="740" width="600" >
                </object>
            </div>
        </td>
    </tr>
</table>
</body>

The JavaScript code that changes the file is:

function navigateToPage(fileLink) {
    document.getElementById("workingSWF").innerHTML = 
    "<object type='application/x-shockwave-flash' data='"+fileLink+"' width='740' height='600'>";
    document.getElementById("workingSWF").focus();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.