-
change html background from flash
im working on a dynamic website where the client can change colour schemes.
this is pretty straight forward in the fla. however is it possible to change the colour of the html page in which the flash file sits?
i guess the page would start out being white then first frame of the swf would adjust its colour?
fs command?
cheers
james
-
Senior Member
There are a couple of possibilities, you can use the bgcolor property of the document object, like this
getURL("javascript:document.bgColor='#ff9900';void (0);");
this would change the background color of the page to ff9900 (orange)
the other option that spings to mind is adjusting the style sheet to apply to a section of the page from flash, this would also allow you to change other things easily, not just the background color. one way to do this could be something like,
<html>
<head>
<title>Style test page</title>
<style type="text/css">
.style1 {background-color: #ffffff; color: #000000; font-family: verdana,helvetica,arial,sans-serif;}
.style2 {background-color: #000000; color: #ffffff; font-family: garamond,times,serif;}
</style>
<script type="text/javascript">
function changeStyle(id, style) {
var obj = document.getElementById(id);
obj.className = style;
}
</script>
</head>
<body id="main" class="style1">
</body>
</html>
you could then call the changeStyle function from your movie by
getURL("javascript:changeStyle('main','style2');") ;
another advantage of this method is you can change the style of other sections in the page, not just the body, all you need to do is give these subsections their own id. Note this method requires a more modern browser that document.bgColor
-
mint!
exactley what i wanted
thanks
james
drag&drop
ps. if your interested the project is at http://www.drag-drop.net/portfolio
-
another quick thing.
if i was to use your bgcolour thing with get url. what would be the code to take the colour from an externally loaded variable say col1.
im loading in dynamic variables from external txt. and want to allow clients to adjust colour the scheme of their site.
thanks again
james
-
Senior Member
Hi,
That shouldn't be a problem, in the textfile create variable, let's say, colour and give it a value, this could be hex or a colour name, eg
&colour=#0099ff&
then when you load the variables you should be able to use,
getURL("javascript:document.bgColor='" + colour + "';void(0);");
[edit]
asuming the getURL is in the same timeline you loaded the variables into
[/edit]
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
|