Okay, it looks like there's not gonna be a "magic bullet" for browser-compatibility versus embedded objects. The javascript-optional method of SWFObject (formerly SWFFix) just admitted as such.
The problem seems to be in the method employed. To get around the IE "click to activate" issue, the content must be streamed through javascript. This, however, causes problems with browsers that don't support javascript. The solution appeared to be to keep the old style "object" tags in-place, but to write some clever javascript that would stealthily replace those object-tags with javascript equivalents where necessary.<br><br>So if you have a javascript-capable browser, you'd get the content. If you have a browser that gripes about "click to activate", it gets around that. If you have a non-javascript browser, it gets around that too. Furthermore, if your Flash version is too low, your browser is silently updated. If you don't have Flash at all, you get a link to the download-Flash-Player page at Adobe.<br><br>Perfect, right?<br><br>Wrong. Turns out that the solution is ultimately. . .<br><br>1. Ugly. Flash applets blink and restart themselves during page-load as they're replaced because they can only be replaced after the entire page is loaded.<br><br>2. Screws up IE. Some IE browsers (like my wife's) have gotten Flash applets that don't properly initialize themselves when they're restarted (which I think is actually a Flash problem, but I'm not sure)<br><br>3. Screws up some versions of Opera 9. Nobody expected this, but it appears to just be an added bonus.<br><br>So the SWFObject folks are going back to the old "don't use object tags and serve all Flash via javascript and if your browser doesn't grok javascript then you're hosed".<br><br>This does rather leave non-javascript browsers in the lurch, but given that the only non-javascript browsers out there are handheld-based (PocketPC, PSP, most phones), it's easy enough to split those off.<br><br>So the solution's gonna go this way. . .<br><br>1. You go to www.thecodezone.com.<br><br>2. The site checks your browser.<br><br>3. If your browser's on my list of non-javascript mobile browsers, then you're gonna be redirected to mobile.thecodezone.com, which will consist of miniature equivalents of all the games served from barebones HTML pages with no scripting<br><br>4. If you're coming from a desktop PC, your applets are served by javascript and everything looks hunky-dory. No "click to activate" or any problems like that.<br><br>And this'll all be deployed with the new-n-improved site, which I'm working on behind the scenes.<br><br><br>On that note, here's a couple of PHP helper-functions I wrote. SWFObject is easy, but it's not quite easy enough for a lazy programmer such as myself. To embed Flash in your app using my helper functions basically requires this in your HTML header.<br><br><?php SWFHeader("applet.swf", 500, 400); ?><br><br>and this in your code wherever you want the applet to appear<br><br><?php SWFContent("applet.swf"); ?><br><br>I wrote this because I was tired of rewriting my embeds. I figure this way if something else changes as far as embedding goes, I can just make the change to these functions.<br><br>I figure I can make a javascript-free version of this pretty easily when it's time to deploy the mobile site.<br><br><!--STARTSCRIPT--><!--source lang="cpp"--><div class="source"><pre><br>function SWFHeader($SWF, $width, $height, $id=NULL, $ver='<span class="cpp-number">7</span>.<span class="cpp-number">0</span>.<span class="cpp-number">0</span>', $flashVars='{}', $flashParams='{}', $flashAttributes='{}')<br>{<br> <span class="cpp-keyword">if</span> (!$id)<br> $id = $SWF;<br> $GLOBALS['_'.$id.'width'] = $width;<br> $GLOBALS['_'.$id.'height'] = $height;<br> echo ('<script type=<span class="cpp-literal">"text/javascript"</span>>swfobject.embedSWF(<span class="cpp-literal">"'.$SWF.'"</span>, <span class="cpp-literal">"'.$id.'"</span>, <span class="cpp-literal">"'.$width.'"</span>, <span class="cpp-literal">"'.$height.'"</span>, <span class="cpp-literal">"'.$ver.'"</span>, <span class="cpp-literal">"'.$GLOBALS['URL_BASE'].'/expressInstall.swf"</span>, '.$flashVars.', '.$flashParams.', '.$flashAttributes.');</script>');<br>}<br><br>function SWFContent($id, $align=<span class="cpp-literal">"center"</span>)<br>{<br> <span class="cpp-keyword">if</span>($GLOBALS['_'.$id.'width'])<br> echo ('<div align=<span class="cpp-literal">"'.$align.'"</span>><div style=<span class="cpp-literal">"width:'.$GLOBALS['_'.$id.'width'].'px;height:'.$GLOBALS['_'.$id.'height'].'px;"</span>><div id=<span class="cpp-literal">"'.$id.'"</span>><p><a href=<span class="cpp-literal">"http://www.adobe.com/go/getflashplayer"</span>><img src=<span class="cpp-literal">"'.$GLOBALS['URL_BASE'].'/images/get_flash_player.gif"</span> alt=<span class="cpp-literal">"Get Adobe Flash player"</span>></a></p></div></div></div>');<br> <span class="cpp-keyword">else</span><br> echo ('<div>ID Not Registered</div>');<br>}<br><br></pre></div><!--ENDSCRIPT--><br><br>And yes, I realize that I have div-tags nested three deep. Mind you, the innermost tag is replaced during loading. And the second tag really isn't necessary but makes the page load look better because all box-sizes are given in the first load, so nothing moves around.<div>
</div>
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Advertisement
Latest Entries
Neato transition effect
3598 views
New Unity3D UI and just general musing.
4522 views
So Dwarf Planet Pirates has grown in scope.
3931 views
Seems to still be working.
2802 views
Advertisement