Flash file modification

I am trying to work out a way to change the flash file displayed on the screen to another file by clicking a button. I was able to do it with jpg images, but I cannot get it to work with flash files. Can anyone please help? I would greatly appreciate it. Below are two html, the first one modifies the jpg images and it works, the second one which I built the same way how to do the same with flash files, but it doesn't work.

// Html 1. This is changing image 1 to image 2 on click. It works

function changeSrc () {document.getElementById ("myImage"). src = "Image 2.jpg"; }



// Html 2. This is for changing Flash 1 to Flash 2 on click. This does not work

function changeSrc () {document.getElementById ("myImage"). src = "Flash 2.swf"; }

   



+1


source to share


2 answers


here you have an example of changing im js built-in flash function:



function setFlashSrc(newSrc)
    {
          var flash='<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" WIDTH="210" HEIGHT="210">';
          flash+='<PARAM NAME=movie VALUE="'+newSrc+'"><PARAM NAME=quality VALUE=high>';
          flash+='<EMBED SRC="'+newSrc+'" QUALITY=high PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ';
          flash+='TYPE="application/x-shockwave-flash" WIDTH="210" HEIGHT="210">';
          flash+='</EMBED>';
          flash+='</OBJECT>';
          document.getElementById("urgeo").innerHTML=flash;
    }

      

+1


source


You need to use the name property of the embed or object tag to get a link to the embedded flash files. Using id won't work.

But there is an easier way to do it. if you are using swfObject to embed your swfs it can be as simple as one javascript call.



<script type="text/javascript">

var flashvars = false;
var params = {
  menu: "false",
  flashvars: "name1=hello&name2=world&name3=foobar"
};
var attributes = {
  id: "myDynamicContent",
  name: "myDynamicContent"
};

swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);

</script>

      

+1


source







All Articles