View Full Version : Controlling HTML layers from a flash movie
roodi
01-15-2003, 10:53 AM
Hi,
Is there a way of controlling HTML layer i.e. show-hide layer from a swf movie? so you can toggle between dynamic layers (Show-Hide layer) rather than toggle between SWF files?
Please see example attached
Thank you
jimburton
01-15-2003, 02:20 PM
you can do it with javascript and call that javascript from flash using getURL....I'm not sure of the javascript syntax offhand, something like document.all["nameOfDiv].visible = false for IE and document.nameOfDiv.show = false for NN
roodi
01-15-2003, 02:39 PM
Thank you for that...the only problem is that am not to good with Javascript:-( could you possibly show an example I would be very grateful.
Thank you
farafiro
01-15-2003, 02:47 PM
I'm sure that jim will do it, but for mean while
u don't need to be that good to do it, just look here for 'javascript' and you will get the idea of how it works very quick
u just need a JS codes sources
like www.devguru.com
www.javascript.com
jimburton
01-15-2003, 03:11 PM
check out those resources fara linked to and I found the tutes at www.webmonkey.com useful too....
in essence these are the steps:
a stylesheet:
<style>
#bidnit{
position:absolute;
top:100px;
left:100px;
width:100px;
height:100px;
color:#fff;
background-color:#000;
visibility:visible;
}
</style>
which defines your "layer" although that's not such a useful term in this context cos it can mean different things - think more in terms of page elements....
the element on the page:
<body>
<span id="bidnit">Whooah bidnit!</span>
... rest of your page...
</body>
and some javascript to manipulate it:
//in the page header
<script language="JavaScript">
function swapVis() {
if (document.all["bidnit"].style.visibility=='hidden') {
document.all["bidnit"].style.visibility = 'visible';
} else {
document.all["bidnit"].style.visibility = 'hidden';
}
}
</script>
then you can call that function to turn the visibility on and off, with a link in the webpage like:
<a href="javascript:swapVis();">swap visibility</a>
or even from a flash movie, using getURL:
getURL("javascript:void(0);swapVis();");
as I said, the way you refer to page elements differs in IE & NN, so you will need to look into this if you want to make something rock solid, more recent browsers will all be OK though.....hope that helps,
roodi
01-15-2003, 04:58 PM
Thank you, I'll give it ago!
roodi
01-15-2003, 05:36 PM
I have had no joy:-( I seem to be getting error messages from my javascript:-(
Please see attachment
Thanks
jimburton
01-15-2003, 11:06 PM
whoah, when did I suggest using macromedia's bloaty javascript functions!;) I hope the attached files, which show the principle working, are useful....:)
roodi
01-17-2003, 03:45 PM
thank you, just need to figure out how to make it work in Netscape:-(
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.