PDA

View Full Version : (HELP!) Hiding and Showing DIVs - using Flash, CSS and Javascript



Ger75
Nov 22nd, 2010, 04:05 PM
Hi,

Sorry for the (HELP!) addition in the title, but i'm just stumped here. I am trying to show and hide div layers when I click on a button in a flash movie. The flash movie is in it's own div and the content below is also in it's own div. Is there a way to call the function from flash so that content in another div is affected?

The code to show and hid layers in html is working and is here:



//visible layers
function $_(IDS) { return document.getElementById(IDS); }

function setVisible( IDS ) {
var obj;
var sel = $_('divContent').getElementsByTagName('div');
for (var i=0; i<sel.length; i++) {
obj = sel[i].id;
if (obj != IDS) { $_(obj).style.display = 'none'; }
else { $_(obj).style.display != 'block' ? $_(obj).style.display="block" : $_(obj).style.display="none"; }
}
}
window.onload = function() {
setVisible('BIO');
};
</script>
</head>

<body>
<div id="navigation">
<a href="#" onClick="setVisible('BIO'); return false;">Who I Am</a><span class="text4"> |</span>
<a href="#" onClick="setVisible('News'); return false;">What's New</a><span class="text4"> |</span>
<a href="#" onClick="setVisible('Portfolio'); return false;">Portfolio</a><span class="text4"> |</span>
<a href="#" onClick="setVisible('Resume'); return false;">Resume</a>
</div>

<div id="divContent">
<div id="BIO" class='divElem'>
<p>This is my content for bio</p>
</div>
<div id="News" class='divElem'>
<pThis is my content for news</p>
</div>
<div id="Portfolio" class='divElem'>
<p><This is my content for portfolio </p>
</div>
<div id="Resume" class='divElem'>
<p>This is my content for resume</p>
</div>
</div>

</body>


Is there a way to call the function in flash on a button? Any help you can give would be GREATLY appreciated.

Thanks and forever indebted.

Gerry

Spudhead
Nov 22nd, 2010, 06:29 PM
You can call javascript functions from within Flash using the ExternalInterface class (http://kb2.adobe.com/cps/156/tn_15683.html)

Ger75
Nov 22nd, 2010, 11:00 PM
Hmmmmm. This seems to get text from flash. I'm trying to show different div layers that have type in them when i a button is pressed in flash. I'm a designer so it's a bit over my head, but i'll try it out. Might resort to just building the whole thing in flash and forgetting the layers. Thanks.