| | |
Javascript/flash onClick Issues
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
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:
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.
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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
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.
Last edited by MattTheHat; May 25th, 2009 at 8:29 am.
Matt,
It's about 8 years since I did anything like this so please forgive me for not recalling every detail.
I was responsible for the javascript side of things while somone else created the swf. As in your problem we had to pass through a flash-click to the js and were just about to give up when my section leader suggested using a VB script as a conduit for the function call. And it worked!!
Fortunately, the whole process is well documented, see this page for example (looks comprehensive). You will see that a vb script is conditionally written for some browser/os combinations. You will need to test thoroughly in as many browsers as possible to make sure that the conditions under which the vb is written cover the latest versions (esp IE 7 and 8).
It's moderately involved, so I reckon you will do well to solve it inside 3 days, even with the help of the guidance. It would take me longer because I would need to learn flash first.
Workaround: Put a "Larger image" HTML button or link outside the flash area.
Good luck.
Airshow
It's about 8 years since I did anything like this so please forgive me for not recalling every detail.
I was responsible for the javascript side of things while somone else created the swf. As in your problem we had to pass through a flash-click to the js and were just about to give up when my section leader suggested using a VB script as a conduit for the function call. And it worked!!
Fortunately, the whole process is well documented, see this page for example (looks comprehensive). You will see that a vb script is conditionally written for some browser/os combinations. You will need to test thoroughly in as many browsers as possible to make sure that the conditions under which the vb is written cover the latest versions (esp IE 7 and 8).
It's moderately involved, so I reckon you will do well to solve it inside 3 days, even with the help of the guidance. It would take me longer because I would need to learn flash first.
Workaround: Put a "Larger image" HTML button or link outside the flash area.
Good luck.
Airshow
Last edited by Airshow; May 25th, 2009 at 8:56 am.
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
Thank you very much, I'll check that out.
The other thing I'm now trying is attempting to get the flash file to call the JavaScript function. I'll see how that goes and if that fails I'll try the VBscript script approach and if that fails I will cry and then add a normal text box with an onClick event!
The other thing I'm now trying is attempting to get the flash file to call the JavaScript function. I'll see how that goes and if that fails I'll try the VBscript script approach and if that fails I will cry and then add a normal text box with an onClick event!
M.T.H.,
Just thought of another workaround.
Depends on how interactive your swf needs to be, but if it is a simple animation, then save it as an animated gif, then serve it either wrapped like this <a href="" onclick="fnCall(); return false;"><img src="myAnim.gif" ... /></a> or with an image map to define clickable area(s) and their action(s).
Airshow
Just thought of another workaround.
Depends on how interactive your swf needs to be, but if it is a simple animation, then save it as an animated gif, then serve it either wrapped like this <a href="" onclick="fnCall(); return false;"><img src="myAnim.gif" ... /></a> or with an image map to define clickable area(s) and their action(s).
Airshow
![]() |
Similar Threads
- Passing an array from javascript to flash (Graphics and Multimedia)
- count clicks for flash... (PHP)
- Javascript problems onClick and calcuations (JavaScript / DHTML / AJAX)
- Javascript Login with Redirection Issues (JavaScript / DHTML / AJAX)
- expanding table in flash/javascript required (JavaScript / DHTML / AJAX)
- javascript code not working in mozillafirefox (JavaScript / DHTML / AJAX)
- help with php and javascript (PHP)
- changing from onclick to onsubmit? possible? (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: trim a string help
- Next Thread: Capturing data from txt file using JavaScript/HTML
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser captcha captchaformproblem cart child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsf jsp jump libcurl listbox maps masterpage math media menu mp4 object onerror onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software star starrating stars synchronous toggle unicode variables w3c web webservice \n





