I'm having a problem with a quite complex piece of code, basically i cannot use an onClick event on my <div></div> element because it contains a flash file that is capturing all the clicks on it. Let me guide you through my code:
It uses an XML document to load .SWF files into layers on a PHP page using JavaScript (talk about code nightmare!). The code is the same on four pages but has to load different numbers of .SWFs depending on the page. The way it does that is by getting the number of elements referenced to the page using it's URL so the page /PGraphics.php sets the variable 'gPageIS' to PGraphics which is a corresponding tag in the XML file.
Here is the code snippet in question:
function setPageAS()
{
//This variable obtains the length of the relevant XML array
gPageISlength = (gXML.getElementsByTagName(gPageIS).length);
//This loop shows the correct number of layers and populates them with their corresponding .SWF; it will loop as many times as there are elements of the correct name in the XML file.
for ( var i = 0; i <= (gPageISlength - 1); i++ )
{
gBoxIdent = ("gBox" + (i + 1));
tempPhrase = (document.getElementById("gboxLAYER").innerHTML);
document.getElementById("gboxLAYER").innerHTML =
(tempPhrase) +
("<div id='") +
(gBoxIdent) +
//this is where i would put the onClick event but it just won't call it when the content is flash.
("' class='gBoxCLASS'></div>");
//this bit gets the contents of the XML tag and puts it in a variable
gBoxLOC = (gXML.getElementsByTagName(gPageIS)[i].childNodes[0].nodeValue);
//adds the content using the gBoxLOC variable to locate the flash file in question.
document.getElementById(gBoxIdent).innerHTML =
("<object type='application/x-shockwave-flash' allowScriptAccess='never' allowNetworking='internal' height='300'width='300' top='0' left='0' align='left' data='") +
(gBoxLOC) +
("' ><param name='allowScriptAccess' value='never' /><param name='allowNetworking' value='internal' /><param name='movie' value='")+
(gBoxLOC) +
("' /></object>");
}
}
gPageIS : contains the name of the page in question also is the name of the XML tags relating to that page.
note: there are 8 predefined gBox layers and never more than 8 elements of a corresponding name in the XML file.
You'll notice there is no onClick in there and that's because i can't get it to work anywhere; i've tried putting it on the layer, on the object tag itself I've even tried calling the javascript function from the flash file's actions but i have very limited understanding of actionscript 3 so this was a failure too.
The code works fine if the content of the layers is anything other than a flash file.
What i want to know is; is there a way to call a function (say makeLarge()) by clicking on the layer?
if not is there some sort of work around i can use?
I've tried to explain exactly what i'm doing here but if you have any questions please ask. Thank you all in advance.