OK I have been looking for a solution for this problem of changing my background color of my HTML page via AS 2.0 (but using JavaScript). I came across many examples but all of them work in versions of Flash player 6 or lower. I am wondering if anyone knows how to make it work in Flash 8 or 9 and for AS2.0.
Here is a link to a site that has a great working copy with the wrong flash player version and using AS 1.0.
http://tutorials.flashvacuum.com/index.php?show=Change_Background_Color
Add the following script to your HTML page:
<script type="text/javascript">
function changeBgColor(newBgColor) {
if (window.document && window.document.bgColor) {
document.bgColor = newBgColor;
}
}
</script>
Now add this script (and the appropriate buttons) to your FLA:
import flash.external.ExternalInterface;
function callJavascript(newBgColor):Void {
// call external function ("function_name", parameter to pass to function_name)
ExternalInterface.call("changeBgColor", newBgColor);
}
my_btn1.onRelease = function() {
// change background to black
callJavascript("#000000");
};
my_btn2.onRelease = function() {
// change background to red
callJavascript("#FF0000");
};
Thanks for this. But for some reason it does not work. Could you possible create the fla and html page and show me what I am doing wrong, and why it wont work.
Ok I found 1 thing wrong with this solution already. It is not for AS2.0 it is for AS1.0. I also have tried to use the getURL() method but that does not work either.
So if anyone knows how I can get this to work with AS2.0 and Flash 8 or 9. Please let me know.
Thanks
I am not saying that it won’t work but I wanted to send you the files I have created and maybe you can tell me what I am doing incorrectly.
Not in CS3 format you won’t. These are in F8
That’s perfect…works like a dream…just what I was looking for…thanks!
Ok this made no sense. But I still cannot get it to work. So in the next couple of days I am going to send you my fla that I am using and teh HTML page. maybe you can let me know why it is still not working.