PDA

View Full Version : Looping alpha filter


Mhtml
12-20-2002, 03:57 AM
Why can't you use for to "fade" an object?
Can you tell me what is happening in this, also is this the only way? (May not be exactly this..trying to remember)

function show(){
Interval = setInterval("fadeit(TheObj)", 10)
}
fadeit(){
if (TheObj.filters.alpha.opacity<100) {
TheObj.filters.alpha.opacity+=5
}else{
close.Interval //or something I can't remember
}
}

Ok I have almost no Javascript knowledge what so ever yet so don't be to heavy with the explanation.

Also a javascript tutorial would be great, not w3schools.com though the tutorial there is horrible, it teaches nothing on js and is boring.

glenngv
12-20-2002, 06:42 AM
you passed an object reference to the fadeit() function but it doesn't need one.
just declare TheObj as global.

var TheObj;
var Interval;
function show(){
Interval = setInterval("fadeit()", 10)
}
function fadeit(){
if (TheObj.filters.alpha.opacity<100) {
TheObj.filters.alpha.opacity+=5
}else{
clearInterval(Interval);
}
}

but I don't know if the fade would work. I just showed you the basic idea of using setInterval/clearInterval

Mhtml
12-20-2002, 08:04 AM
For some strange reason I think I get what you just said! I'm picking this up.:)

Mr J
12-23-2002, 05:14 PM
Does this help?



<span id="fade" style="position:absolute;left:0;top:50;visibility:hidden;text-align:center; filter:alpha(Opacity=10) ;z-index:1">Hello World</span>
<SCRIPT LANGUAGE="JavaScript">
<!--
startcount=0
endcount=50

function fademe(){
startcount++
document.all.fade.style.fontSize=80
document.all.fade.filters.alpha.Opacity=startcount*(100/endcount)
document.all.fade.style.color="#000000"
document.all.fade.style.visibility="visible"
timer=setTimeout("fademe()",50)

if(startcount>=endcount){
clearTimeout(timer)
startcount=0
document.all.fade.filters.alpha.Opacity=0
setTimeout("fademe()",500)
}
}
setTimeout("fademe()",1000)
// -->
</SCRIPT>