- Home
- Tutorials
- Flash
- Intermediate
- Changing a HTML page's background color via Flash

Page 2 of 2
Step 3
Publishing
Now we will publish our movie after checking the HTML format type option in the publish settings.I wanted the background color of my Flash file to change according to the background color of the web page, so when publishing the movie I have checked the windowless transparent option.Publish the movie and save your file.
Now open the HTML file source with your favorite editor and add the JavaScript code (refer to the step 1) between the <HEAD> and </HEAD> section of the HTML file. Save it and check it.
Bugs
This technique works in Netscape 6 on Windows, but the background color of the Flash file doesn't change according to the background color of the web page.
Discussion
"JavaScript:" in getURL feature is not supported by some browser versions and platforms. (See the Summary for details).
Our innocent JavaScript doesn't do anything special (we just change the background color of our web page) but using that simple example and your scripting knowledge you can implement more useful interactions. For example, you can make a IE specific add to favorites button (using the "window.external.AddFavorite" method) or Netscape 6 specific add to sidebar button (using the "window.sidebar.addPanel" method), or you can open a new browser window (using the "window.open" method) etc.
At that point, one might ask if we really need to write our JavaScript code in the HTML page, because we can write it in our ActionScript code too. For example, let's say you want to pop out an alert box from your Flash file. Make a new movie, create a button and just add this action to the button:
on (press) {
getURL ("JavaScript:alert('This is Flash!')");
}
Publish your movie and test it with JavaScript compliant browsers. It will work. You don't need to write any JavaScript code in your HTML. But this technique has drawbacks too; if the code is too complex it would be better to use JavaScript, also if you will use a IE or Netscape specific method, first you will have to redirect users to appropriate pages, etc.

