PDA

View Full Version : detecting focus away from swf: part II: setVariable()


emergency_pants
12-07-2004, 05:06 PM
I thought I'd solved my focus issue, but I was gutted to find that it doesn't work on Mozilla/Firefox. :( :mad: :( :eek:

I've tried searching for answer, but haven't found anything viable.

Can someone take a look and tell me what I'm doing wrong?

<SCRIPT LANGUAGE=JavaScript>
function swfOn(){
var swf = document.getElementById("swf");
var logo = document.getElementById("logo");
swf.style.zIndex = "10";
var movieActive = "true";
document.finder.setVariable("movieActive", movieActive);
}
function swfOff(){
var swf = document.getElementById("swf");
var logo = document.getElementById("logo");
swf.style.zIndex = "0";
var movieActive = "false";
document.finder.setVariable("movieActive", movieActive);
}
</SCRIPT>
</head>
<body>
<div id="swf">
<object onblur=swfOff() onfocus=swfOn() classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
width="600" height="382" id="finder">
<param name="movie" value="finder.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<embed src="finder.swf" width="600" height="382" quality="high" wmode="transparent" name="finder" swliveconnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
</object>


See the "onblur=swfOff() onfocus=swfOn() " at the start of the <object...

The swfOn() and swfOff() functions are being called because the zIndex part of the function is working!! So it's just the setVariable() command which doesn't seem to work.

As I say, it works PERFECTLY on IE, but not at all on Mozilla/Firefox.

This is thoroughly doing my head in. :(

emergency_pants
12-07-2004, 05:38 PM
I thought I'd follow up with a solution.

I found some details here:
http://www.markme.com/teammmflash/archives/005316.cfm

I needed to place a test to see what browser type was being used and then set the swf reference accordingly, either "window.myswf" or "document.myswf".

Below is the complete javascript and object/embed tag to see how its done.


<SCRIPT LANGUAGE=JavaScript>
var movieName = "finder";

function thisMovie(movieName) {
if (navigator.appName.indexOf ("Microsoft") !=-1) {
return window[movieName]
} else {
return document[movieName]
}
}

function swfOn(){
var swf = document.getElementById("swf");
var logo = document.getElementById("logo");
swf.style.zIndex = "10";
var movieActive = "true";
thisMovie(movieName).SetVariable("movieActive", movieActive);
}

function swfOff(){
var swf = document.getElementById("swf");
var logo = document.getElementById("logo");
swf.style.zIndex = "0";
var movieActive = "false";
thisMovie(movieName).SetVariable("movieActive", movieActive);
}
</SCRIPT>
</head>
<body>
<div id="swf">
<object onblur=swfOff() onfocus=swfOn() classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
width="600" height="382" id="finder">
<param name="movie" value="finder.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<embed src="finder.swf" width="600" height="382" quality="high" wmode="transparent" name="finder" swliveconnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
</object>


My swf is on a layer, it is called "finder.swf" The div is called "swf"
The object tag starts with two calls:
onblur=swfOff()
When the user clicks away from the swf, swfOff() is called
The zIndex of the swf layer is swapped to zero. This makes the links underneath the swf layer available for clicking!
Also, a variable is sent to the swf, setting the movieActive to "off".
The swf is running an enterFrame script, which closes any popup windows whenever movieActive is "off".

onfocus=swfOn()
When a user clicks ON the swf, the opposite of the above occurs. The swf layer zIndex is set to 10 and the movieActive is set to "true".

I thought I'd explain how I did this because perhaps it can be useful to someone else banging their head against the wall on this one.

Hope that helps someone, somewhere, somehow.

imagenesis
04-01-2009, 03:58 AM
This someone is here. Google has brought me to you. The funny part is that it was the first search result in queries to my answer yet I didn't click on it because the title and description of the search result didn't really match I thought. Haha, damn you Google, you artificially intelligent mofo.

imagenesis
04-01-2009, 04:00 AM
http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=setvariable+wmode+transparent&btnG=Search

http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=setvariable+work+wmode+transparent&btnG=Search

http://www.google.com/search?q=setvariable+doesnt+work+when+wmode+transp arent&hl=en&client=firefox-a&rls=org.mozilla:en-US:official&hs=3UC&start=10&sa=N

http://www.google.com/search?q=setvariable+doesnt+work+when+wmode+transp arent&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

imagenesis
04-01-2009, 05:45 AM
Ugh this still doesnt work. If wmode is set to transparent, Firefox stops executing SetVariable properly. I've tried accessing the actual flash embed object a bunch of different ways.

tacos
04-01-2009, 06:13 AM
What's your problem exactly? What are you trying to do?