[SWFObject] swfobject to embed documents in popups?

Carl Hudon carl.hudon at mahjongmania.com
Fri Oct 20 07:35:25 PDT 2006


  Hello everyone,

We are working on a flash based game here and have been asked to add 
some informational bits and controls outside of the main game window 
(yes, we have tried to get that idea out of the management's head but to 
no avail). Bottom line is we now have to pop other flash apps/comps that 
will live in window.open'ed browser windows. the rest is cake...  
problem is, when we write our flash objects in the new window, we havent 
been able to get rid of the dreaded "click here..." activation control 
in IE also the flashcontent DIVs in the popped windows wont get 
re-written in firefox (strangely enough). It does work fine in our main 
app window (IE and Firefox) but all the popped ones get the activation 
barrier. It may be the way we implemented the SWFObjects but so far we 
are running out of ways to try. If you guys can help it would rock. here 
is a simple form of what we want to do.

NOTE: I have modified the swfobject function write() for testing 
purposes to include an extra param (doc) wich is the window.document 
target object on which you want to write. Not quite working yet it 
seems. help?

NOTE: there are DIV elements with proper names on each HTML pages im 
using. (read a comment from someone with same error that didnt have 
them. Not the problem in this case.


_modified swfobject.js_

/write: function(doc, elementId){
        if(this.getAttribute('useExpressInstall')) {
            // check to see if we need to do an express install
            var expressInstallReqVer = new 
deconcept.PlayerVersion([6,0,65]);
            if (this.installedVer.versionIsValid(expressInstallReqVer) 
&& !this.installedVer.versionIsValid(this.getAttribute('version'))) {
                this.setAttribute('doExpressInstall', true);
                this.addVariable("MMredirectURL", 
escape(this.getAttribute('xiRedirectUrl')));
                doc.title = doc.title.slice(0, 47) + " - Flash Player 
Installation";
                this.addVariable("MMdoctitle", doc.title);
            }
        }
        if(this.skipDetect || this.getAttribute('doExpressInstall') || 
this.installedVer.versionIsValid(this.getAttribute('version'))){
            var n = (typeof elementId == 'string') ? 
doc.getElementById(elementId) : elementId;
            //alert("doc: " + doc + " string?: " + (typeof elementId == 
'string') + " :    elementId: " + elementId);
            n.innerHTML = this.getSWFHTML();
            return true;
        }else{
            if(this.getAttribute('redirectUrl') != "") {
                doc.location.replace(this.getAttribute('redirectUrl'));
            }
        }
        return false;
    }
}/


_multi.swf_
some button has this code on a release listener:

/getURL("javascript:popUp('" + newChannel + "', '" + jsVars + "', 
'scrollbars=auto,status=no,location=no,menubar=no,toolbar=no,resizable=no,width=500,height=300');");    

/_index.html

_/<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Multi Panel Application</title>
    <script src="swfobject.js" language="javascript"></script>
    <script type="text/javascript" language="Javascript">
        <!--
        var chanels = new Array();
        function popUp(windowName, gameID, windowParams){
            chanels[windowName] = window.open("info.html", windowName, 
windowParams);
            var tmp = chanels[windowName].document;
            var so = new SWFObject("client.swf", "client", "300", "300", 
"7", "#FFFFFF");
            var flVars = gameID.split("=");
            so.addVariable(flVars[0], flVars[1]);
            
so.write(chanels[windowName].document.getElementById('flashcontent'));
        }
        -->
    </script>
</head>
<body bgcolor="#ffffff">
    <div id="flashcontent">
       Flash Content Here...
    </div>
    <script type="text/javascript">
        // <![CDATA[
        var so = new SWFObject("multi.swf", "multi", "300", "300", "7", 
"#FFFFFF");
        so.write("flashcontent");
        // ]]>
    </script>
</body>
</html>

/_info.html

_/<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Game Panel</title>
</head>
    <body>
        <div id="flashcontent">
            Flash Content Here...
        </div>
    </body>
</html>

/_CLIENT.SWF

_/some swf file with a text field that will display whatever has been 
passed to the flash file from added parameters in SWFObject.

This works "fine" on IE6 even tho trying to trace the DIV object's 
properties on the calling page return an error while Firefox 1.5 will 
trace the object's entire props list and will not be able to access it 
on the called page making the write() call bomb on line 105; "n has no 
properties" <- cannot resolve the DIV element by its name).

/
i've also dropped a demo of this here. <http://www.coresplit.com/swfo/>

Cheers,

Carl Hudon/
/_

_
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.deconcept.com/pipermail/swfobject-deconcept.com/attachments/20061020/a487348d/attachment-0004.htm>


More information about the Swfobject mailing list