Reply to topic
Embedding flash to validate in XHTML
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
have u tried to embed your flash video and still have it throw a major crap when u try to validate it?

well the problem is that <embed> in a depriciated tag so xhtml will choke on it

but this works


Code:
<!-- insert flash swf to be compliant -->
<object type="application/x-shockwave-flash"
data="movie.swf" width="500" height="500">
<param name="movie" value="movie.swf" />
</object>



and there u have it!
T.J


Joined: 23 Mar 2005
Posts: 2
Reply with quote
Hey... I'm trying to embed some flash on a website and it's definately giving me a hard time. I tried the code that was given when I used publish:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="650" height="150" id="Banner" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="Banner.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="Banner.swf" quality="high" bgcolor="#ffffff" width="650" height="150" name="Banner" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

Then I tried your code modified:

<object type="application/x-shockwave-flash"
data="Banner.swf" width="500" height="500">
<param name="Banner" value="Banner.swf" />
</object>

And neither of them are working for me! I just want my flash banner on my site. Any help would be awesome... thanks!

-TJ
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
are you sure the path to the swf file is correct? is the swf in the same folder or outside of it?

and leave this line like this
<param name="movie"
bobum
Elvis Fanatic
Elvis Fanatic

Joined: 16 Nov 2004
Posts: 746
Location: Montgomery, AL
Reply with quote
Lofty is right here - it's probably a path issue that is giving you problems here...not the actual code.
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
i have a new way thats pretty darn cool, created from a java object and has some pretty sweet flash detection in it so you don't have to have seperate pages for that.
bobum
Elvis Fanatic
Elvis Fanatic

Joined: 16 Nov 2004
Posts: 746
Location: Montgomery, AL
Reply with quote
seperate pages for what?
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
flash player and version detection
T.J


Joined: 23 Mar 2005
Posts: 2
Reply with quote
I figured it out, thanks a bunch. That code works perfectly.
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
check this out

embed the swf
Code:
<script type="text/javascript">
   
   var flashban_top = new FlashObject("http://www.yoursite.com/folder/movie.swf", "ban_top", "718", "150", 6, "#ffffff");
   flashban_top.write();
   
   </script>


include a js file with this code

Code:
FlashObject = function(swf, id, w, h, ver, c) {
   this.swf = swf;
   this.id = id;
   this.width = w;
   this.height = h;
   this.version = ver || 6; // default to 6
   this.align = "middle"; // default to middle
   this.redirect = "";
   this.sq = document.location.search.split("?")[1] || "";
   this.altTxt = "Please <a href='http://www.macromedia.com/go/getflashplayer'>upgrade your Flash Player</a>.";
   this.bypassTxt = "<p>Already have Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
   this.params = new Object();
   this.variables = new Object();
   if (c) this.color = this.addParam('bgcolor', c);
   this.addParam('quality', 'high'); // default to high
   this.doDetect = getQueryParamValue('detectflash');
}

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

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

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

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

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

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

FlashObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

FlashObject.prototype.getHTML = function() {
    var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // 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() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    else { // Everyone else
        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() != null) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    }
    return flashHTML;   
}


FlashObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}

FlashObject.prototype.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 (elementId) {
            document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
         } else {
            document.write(this.altTxt +""+ this.bypassTxt);
         }
      }
   }      
}

function getFlashVersion() {
   var flashversion = 0;
   if (navigator.plugins && navigator.plugins.length) {
      var x = navigator.plugins["Shockwave Flash"];
      if(x){
         if (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) {   
   if (getFlashVersion() >= ver) {
      return true;
   } else {
      return false;
   }
}

// get value of querystring param
function getQueryParamValue(param) {
   var q = document.location.search;
   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;
   }
}
ssi


Joined: 07 Nov 2005
Posts: 1
Reply with quote
Thanks loftboy! You saved me from having to spend the time writing the javascript myself.

For anyone interested, I made a small (very simple) addition so that you can specify the window mode.

Code:
<script type="text/javascript">
   var flashban_top = new FlashObject("http://www.yoursite.com/folder/movie.swf", "ban_top", "718", "150", 6, "#ffffff","transparent");
   flashban_top.write();     
</script>


Code:

FlashObject = function(swf, id, w, h, ver, c, wm) {
   this.swf = swf;
   this.id = id;
   this.width = w;
   this.height = h;
   this.version = ver || 6; // default to 6
   this.align = "middle"; // default to middle
   this.redirect = "";
   this.sq = document.location.search.split("?")[1] || "";
   this.altTxt = "Please <a href='http://www.macromedia.com/go/getflashplayer'>upgrade your Flash Player</a>.";
   this.bypassTxt = "<p>Already have Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
   this.params = new Object();
   this.variables = new Object();
   if (c) this.color = this.addParam('bgcolor', c);
   if (wm) this.addParam('wmode', wm);
   this.addParam('quality', 'high'); // default to high
   this.doDetect = getQueryParamValue('detectflash');
}

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

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

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

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

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

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

FlashObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

FlashObject.prototype.getHTML = function() {
    var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // 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() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    else { // Everyone else
        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() != null) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    }
    return flashHTML;   
}


FlashObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}

FlashObject.prototype.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 (elementId) {
            document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
         } else {
            document.write(this.altTxt +""+ this.bypassTxt);
         }
      }
   }       
}

function getFlashVersion() {
   var flashversion = 0;
   if (navigator.plugins && navigator.plugins.length) {
      var x = navigator.plugins["Shockwave Flash"];
      if(x){
         if (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) {   
   if (getFlashVersion() >= ver) {
      return true;
   } else {
      return false;
   }
}

// get value of querystring param
function getQueryParamValue(param) {
   var q = document.location.search;
   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;
   }
}
Embedding flash to validate in XHTML
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic