Go Back   SitePoint Forums > Forum Index > Design Your Site > Web Page Design > HTML and XHTML
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Dec 16, 2005, 05:28   #1
mediaman_12
SitePoint Addict
 
Join Date: Mar 2003
Location: UK
Posts: 246
Problems with Valid Flash (I know about Satay)

Ok So I know about the non-valid rubish that Flash & DW use to put Flash on an HTML page. and this is the mathod I have been using to do ut manually.
Code:
<object type="application/x-shockwave-flash" data="Flash/mov.swf" class="discountflash">
    	  <param name="quality" value="high">
    	  <param name="wmode" value="transparent">
    	  <param name="movie" value="Flash/mov.swf">
    	  <!-- ugly but Spider frendly 'hidden' copy replaces this comment tag Use simple html formating to increase search rankings-->
		  <img src="Images/nonflashimages/fill image.jpg" width="725" height="113" alt="get flash">
        </object>
This was working nicely until I realised that prelloaders don't work in IE (I don't use IE a lot, I also Have broardband so didn't notice)
So I did a seach and came across Drews Flash Satay article, But I can't seam to get the container movie to load the main flash swf file?
I created a container mov with just the
Code:
root.loadMovie(_root.path,0);
AS on the first (and only) frame. and put "Flash/cont.swf?path=Flash/mov.swf" in the paths of the above method, but it doesn't work? the flash container loads in, I put a square on it so I could see if it was loading, but it doesn't load the main swf.
Any ideas, some browser setting can't overide this, or the latest Flash plugin stopping it from working?
mediaman_12 is offline   Reply With Quote
Old Dec 16, 2005, 07:13   #2
spudz
SitePoint Addict
 
Join Date: May 2005
Posts: 238
Try this:

All of the code here is by Geoff Stearns of deconcept.com. Check out the entire explanation here

Code:
var FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver;
	this.align = "middle";

	this.params = new Object();
	this.variables = new Object();

	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.bypassTxt = "<p>Already have Macromedia Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
	
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'high'); // default to high
	this.doDetect = getQueryParamValue('detectflash');
}

var FOP = FlashObject.prototype;

FOP.addParam = function(name, value) { this.params[name] = value; }

FOP.getParams = function() { return this.params; }

FOP.getParam = function(name) { return this.params[name]; }

FOP.addVariable = function(name, value) { this.variables[name] = value; }

FOP.getVariable = function(name) { return this.variables[name]; }

FOP.getVariables = function() { return this.variables; }

FOP.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    return (paramTags == "") ? false:paramTags;
}

FOP.getHTML = function() {
    var flashHTML = "";
    if (navigator.plugins && navigator.mimeTypes.length) { // netscape plugin architecture
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs()) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    } else { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
        if (this.getParamTags()) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    return flashHTML;	
}

FOP.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) { 
    	variablePairs.push(name + "=" + escape(this.getVariable(name))); 
    }
    return (variablePairs.length > 0) ? variablePairs.join("&"):false;
}

FOP.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else if (this.altTxt) {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}

/* ---- detection functions ---- */
function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			var y = x.description;
   			flashversion = y.charAt(y.indexOf('.')-1);
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectFlash(ver) {	return (getFlashVersion() >= ver) ? true:false; }

// get value of query string param
function getQueryParamValue(param) {
	var q = document.location.search || document.location.href.split("#")[1];
	if (q) {
		var detectIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", detectIndex) > -1) ? q.indexOf("&", detectIndex) : q.length;
		if (q.length > 1 && detectIndex > -1) {
			return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
		} else {
			return "";
		}
	}
}

/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item) { this[this.length] = item; return this.length; }
}
Save it as
Code:
<script type="text/javascript" src="flashobject.js"></script>
Then use this to display the Flash
Code:
<div id="flashcontent">
  Place your alternate content here and users without the Flash plugin
  or with Javascript turned off will see this.
  Include a link to <a href="?detectflash=false">bypass the detection</a>
  if you wish.
</div>
<script type="text/javascript">
 // <![CDATA[
  var fo = new FlashObject("fo_tester.swf", "fo_tester", "300", "150", 6, "#336699");
  fo.write("flashcontent");
 // ]]>
</script>
spudz is offline   Reply With Quote
Old Dec 19, 2005, 02:16   #3
mediaman_12
SitePoint Addict
 
Join Date: Mar 2003
Location: UK
Posts: 246
Wow that's more content heavy and complex than the over long crap that the Flash Application spits out.

So there's a choice of having the Page validate, but not preload. Not validate, but but preload properly. Or have valid HTML, with a preloader that works, but you have to bloat up the page with a huge javascript in the process.

This method also doesn't allow really useful stuff you can put in the <param /> tags like FLASHVARS (for passing verables to the linked flash file) and BASE for setting up the root value for the Flash file.
mediaman_12 is offline   Reply With Quote
Old Dec 19, 2005, 02:43   #4
zcorpan
bronze trophy
 
Join Date: Dec 2004
Location: Sweden
Posts: 2,462
If you don't care about validation then I believe this works cross browser:
HTML Code:
<embed type="application/x-shockwave-flash" src="Flash/mov.swf" width="300" height="150">
It doesn't provide as good fallback as object does, though.
zcorpan is online now   Reply With Quote
Old Jan 19, 2006, 04:23   #5
brownchild
SitePoint Enthusiast
 
Join Date: Jan 2006
Posts: 63
Quote:
So there's a choice of having the Page validate, but not preload. Not validate, but but preload properly. Or have valid HTML, with a preloader that works, but you have to bloat up the page with a huge javascript in the process.
im about to jump onto the FlashObject method of detecting flash..... so about the FlashObject java routine .. is it really THAT heavy? im not a JAva Script guy at all so i have no idea how the java engine crunches those lines of code..

what i know is im about to use the FlashObject script on each of my webpage in my main MASTHEAD/HEADER which is Flash+Main Navigation.. please advise.
brownchild is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 17:47.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved