|
-
script question
I tried on another forum but didn't get an answer.
Is it possible to have a javascript at a Key frame which will fade the background color of the BODY of the webpage from white to black while the Flash movie is playing?
Can anyone help?
Thank You
-
Can't Re- Member
Try this. Cheers.
Place the script right after the html body tag and insert a new parameter into the flash part of the code.
<param name="wmode" value="transparent">
<SCRIPT LANGUAGE="Javascript">
<!--
function makearray(n) {
this.length = n;
for(var i = 1; i <= n; i++)
this[i] = 0;
return this;
}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
function hex(i) {
if (i < 0)
return "00";
else if (i > 255)
return "ff";
else
return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}
function setbgColor(r, g, b) {
var hr = hex(r); var hg = hex(g); var hb = hex(b);
document.bgColor = "#"+hr+hg+hb;
}
function fade(sr, sg, sb, er, eg, eb, step) {
for(var i = 0; i <= step; i++) {
setbgColor(
Math.floor(sr * ((step-i)/step) + er * (i/step)),
Math.floor(sg * ((step-i)/step) + eg * (i/step)),
Math.floor(sb * ((step-i)/step) + eb * (i/step)));
}
}
// CHANGE HERE!
// the first three numbers after "fade(" are the starting RGB values,
// the second set of three numbers are the ending RGB values of the fade.
// the seventh number is the amount of steps or color changes from starting
// RGB values to ending RGB values.
// ex. fade(255,255,255,0,0,0,125) this starts out white (255,255,255 = white)
// and ends black (0,0,0 = black) with 125 steps in between.
function fadein() {
fade(255,32,1, 255,255,255, 125);
}
fadein();
// -->
</SCRIPT>
Or This,,it's much simpler but not so effective......
<SCRIPT>
<!--
function BgFade(red1, grn1, blu1, red2,
grn2, blu2, steps) {
sred = red1; sgrn = grn1; sblu = blu1;
ered = red2; egrn = grn2; eblu = blu2;
inc = steps;
step = 0;
RunFader();
}
function RunFader() {
var epct = step/inc;
var spct = 1 - epct;
document.bgColor =
Math.floor(sred * spct + ered *
epct)*256*256 +
Math.floor(sgrn * spct + egrn * epct)*256 +
Math.floor(sblu * spct + eblu * epct);
if ( step < inc ) {
setTimeout('RunFader()',50);
}
step++;
}
BgFade(0x00,0x00,0x00, 0xFF,0xFF,0xFF,10);
//-->
</SCRIPT>
Last edited by gusmus; 02-05-2004 at 08:16 PM.
humanus somes est divinitus in ipsum
Wiliiam Wallace
-
undead creature
Re: script question
Originally posted by gkrawczyk
I tried on another forum but didn't get an answer.
Is it possible to have a javascript at a Key frame which will fade the background color of the BODY of the webpage from white to black while the Flash movie is playing?
Can anyone help?
Thank You
If I'm not wrong,you need a Flash button (or something similar) to control a HTML page (ON/OFF for that background effect).
You can't do it for the HTML - SWF combination,because you need to send a variable from the SWF file to the HTML file.
DYNAMIC pages (PHP,CGI,ASP,etc) are required in order to do that.
HTML is a STATIC page !
-
Can't Re- Member
You're right Necro, those scripts only work when the page loads. I misunderstood about wanting it to be triggered by the flash, I suppose he could put a timing script on it but it would be impossible to synchronise it with the movie. Cheers.
humanus somes est divinitus in ipsum
Wiliiam Wallace
-
background fade
Thank you for the replies.
I take it the answer is no to having the BODY element fade during a Flash movie unless I add a button. Bummer!
-
Can't Re- Member
Why don't you make a background movie, set the size to width=100% height = 100% (in the generated html), now draw a rectangle to the full size of the movie frame, Use that rectangle to do your colour fades and import your other movie as an object.
Actually, thinking about it, you could start off with a completely empty movie as the base, (same rules for the width and height), then import your "background fade" movie, and your main movie. You can then use the empty movie to control and synchronise the other two so that the fades occur when you want them to. I think it could be done that way, no doubt someone will yell if I'm wrong. Cheers.
Last edited by gusmus; 02-06-2004 at 10:36 AM.
humanus somes est divinitus in ipsum
Wiliiam Wallace
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|