hi, is there a script that alows you to change the backgroundimage you use in your html from within flash?
Hope i’m being clear here…
hi, is there a script that alows you to change the backgroundimage you use in your html from within flash?
Hope i’m being clear here…
bumpercars
Here goes:
You’re going to need some functions to place in your head tag.
<script language="JavaScript1.2" type="text/javascript">
function ChangeBgImg(imgs) {
bdy[0].style.backgroundImage = 'url('+imgs+')';
}
function ChangeBgImgInit() {
bdy = document.getElementsByTagName("body");
bdy[0].style.width = "100%";
bdy[0].style.height = "100%";
bdy[0].style.margin = "0px";
bdy[0].style.backgroundImage = 'url(1.jpg)';
}
onload=ChangeBgImgInit;
</script>
Now you’re going to need to call the ChangeBgImg(imgs) function from within flash. Here’s a simple button that will change the background image.
on(release) {
getURL("javascript: ChangeBgImg('2.jpg')");
}
All you need do now is place your images in the same folder as the swf and html file, for simplicity and create some more buttons, for example, to change the background image with flash!
If you look at the onload bit, after the second function is defined, this loads the first background image you want i.e. 1.jpg. In the above flash button example image 2.jpg replaces the background.
The width, height and margin has been set to fix a NS6 bug.
These functions were create by Made by Martial Boissonneault © 2001 http://getElementById.com/. He gives them freely if he’s mentioned with a comment.
Hope this helps
thanks a lot… exactly what I’m looking for.
Glad to of helped, I wanted to know that same thing the other day. ICQ me if you need any help with it
Wow man - that’s a great bit of code.
thanks a lot for that!
Or you can try this…
Between your head tags in your HTML file try this…
<SCRIPT LANGUAGE="JavaScript">
<!--
function changeColor(color){
document.bgColor = color;
}
-->
</SCRIPT>
Then you can call that in Flash with…
on (release){
getURL("javascript:changeColor('#E6E6E6')");
}
You can change #E6E6E6 to whatever you want.
PS: Java script is supposed to read Javascript (no space in between)
on(release) {
getURL("javascript: ChangeBgImg('2.jpg')");
}
Yea, make sure that javascript has no spaces in it. Thanks lost. ■■■■ typos.
The JavaScript above has no typos though, just checked through it and and did a quick test again.
Yeah the board adds that space for some reason… I have no clue why.
I just posted the above with the, php tags, which I copied and pasted from the Actions Panel Text editor. The text <b>javascript</b> was just like that. When I put the copied and pasted code from the Flash ActionScript editor and post it as php here at the forum it splits <b>javascript</b> into <b>java script</b>.
This is weird. This definately happen, I just check what I copied and pasted from. Try this your self. Has anyone got any idea how or why this happens? I’ve had this happen before on a previous post. :x
Refer to my previous post…lol.
How did you know what I was going to post and post before me.
lol
wow lostinbeta! great code, it’s a “keeper”
marc: telepath
subquark: thanks And I assume your footer never stops “loading” as I am on cable and have just realized that I have never seen it NOT loading…lol.
hahaha, I was thinking the same thing
Thanks for the code lost - very nice…
No problem man Glad you guys like it. I once created a full out RGB selector for your background. Kinda like the swatch panel in Photoshop.
I deleted it though, it was lame IMO. It really served no purpose for me.
just to let you know… it works like a charm.
thanks alot !
cool
:: Copyright KIRUPA 2024 //--