all groups > flash (macromedia) > october 2005 >
You're in the

flash (macromedia)

group:

Flash & Div Layers



Re: Flash & Div Layers travissellers NO[at]SPAM cybercom-intl.com
10/21/2005 8:38:45 PM
flash (macromedia): You can create a div, absolutely position it, and then hide it all
through javascript... Here is a basic example below that centers the
div (you will need to adjust to your div size).

**
javascript and css
**

<script language="javascript">

var myBrowser = null;
if(document.all) {
myBrowser = "IE";
} else if(document.layers) {
myBrowser = "NN";
} else if(document.getElementById) {
myBrowser = "DOM";
}

// gets a layer's height
function getlayerheight(thisLayer) {
if(myBrowser == "NN") {
return(thisLayer.document.height);
} else if(myBrowser == "IE" || myBrowser == "DOM") {
return(thisLayer.offsetHeight);
}
}

// gets a layer's width
function getlayerwidth(thisLayer) {
if(myBrowser == "NN") {
return(thisLayer.document.width);
} else if(myBrowser == "IE" || myBrowser == "DOM") {
return(thisLayer.offsetWidth);
}
}

// gets window height
function getwindowheight(thisWindow) {
if(myBrowser == "NN" || myBrowser == "DOM") {
return(thisWindow.innerHeight);
} else if(myBrowser == "IE") {
return(thisWindow.document.body.clientHeight);
}
}

// gets window width
function getwindowwidth(thisWindow) {
if(myBrowser == "NN" || myBrowser == "DOM") {
return(thisWindow.innerWidth);
} else if(myBrowser == "IE") {
return(thisWindow.document.body.clientWidth);
}
}

// moveTo-functionality
function movelayer(thisLayer, xPos, yPos) {
if(myBrowser == "NN") {
thisLayer.moveTo(xPos, yPos);
} else if(myBrowser == "IE" || myBrowser == "DOM") {
thisLayer.style.left = xPos + "px";
thisLayer.style.top = yPos + "px";
}
}

// logic to center a layer with ID
function centerlayer(thisID) {
var winWidth, winHeight, myWidth, myHeight, myLayer, xPos, yPos;
winWidth = getwindowwidth(self);
winHeight = getwindowheight(self);
if(myBrowser == "NN") {
myLayer = document.layers[thisID];
} else if(myBrowser == "IE") {
myLayer = document.all[thisID];
} else if(myBrowser == "DOM") {
myLayer = document.getElementById(thisID);
}
myWidth = getlayerwidth(myLayer);
myHeight = getlayerheight(myLayer);
xPos = Math.floor((winWidth-myWidth)/2);
yPos = Math.floor((winHeight-myHeight)/2);
movelayer(myLayer, xPos, yPos);
}

function showlayer(id) {
var lyr = getelemrefs(id);
lyr.css.top = 100;
if (lyr && lyr.css) lyr.css.visibility = "visible";
centerlayer(id);
}

function hidelayer(id) {
var lyr = getelemrefs(id);
if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getelemrefs(id) {
var el = (document.getElementById)? document.getElementById(id):
(document.all)? document.all[id]: (document.layers)?
document.layers[id]: null;
if (el) el.css = (el.style)? el.style: el;
return el;
}
</script>
<style>#lyr1 { Z-INDEX: 100; VISIBILITY: hidden; POSITION: absolute }
</style>


**
In your html body create a div with your flash movie html in it...
**

<div id="lyr1" style="visiblity: hidden" height="288" width="400">
<!-- embed your flash movie in this div -->
</div>

**
this is set up to be invisible at the beginning...
you would remove style="visibility: hidden" above on the div tag and in
the <style> to show it at the beginning...

to show the div call:
showlayer("lyr1");
** Note this centers it too in the show layer function :)

to hide it call
hidelayer("lyr1");

so in your flash movie, when you are ready to hide the layer, call:
getURL("javascript:hidelayer('lyr1');");
and that will hide the layer with your centered flash movie...

I use this on a .net application that uses ADSI scripts to manage IIS
sites on remote servers... I popup a little flash animation while it is
posting back (creating sites, etc) that take a while...

Travis




**
[quoted text, click to view]
Flash & Div Layers CanonBoy
10/21/2005 9:19:05 PM
Is it possible to have Flash content on a DIV layer play and then hide the
actual layer the Flash Content is on after a specified time? Maybe by using a
META refresh tag?

This is hypothetical, and the only way true progress in technology is made,
but I wondered if anyone has played with the integration of a swf file and all
the uses of CSS, HTML, DHTML and Javascript other than just plopping a swf file
in a table cell or in the body content.

AddThis Social Bookmark Button