Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > HTML and JavaScript

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-12-2005, 12:20 AM   #1
MrMurk
Registered User
 
Join Date: Feb 2005
Posts: 2
Default Change HTML background color from Flash??

I need a little help on how to change the background of an HTML page containing a flash movie...from a button inside the flash movie...thanks in advance
MrMurk is offline   Reply With Quote
Old 02-12-2005, 02:29 AM   #2
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,026
Default

You can create a JavaScript function to change the background of the HTML page containing the flash movie. From within flash, you can call that JavaScript function with getURL("Javascript:FunctionName(); )
__________________
Color Wars™ | (kul′ər wôrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 08-13-2005, 10:00 PM   #3
inhan
it's all about patience
 
inhan's Avatar
 
Join Date: Jun 2005
Location: istanbul
Posts: 5,859
Default found it out!

I have been looking for this feature last 3 days with many methods of research in the Net. So here it is, working great:

ActionScript Code:
on (release) {     getURL("javascript:document.body.background='new_bg_pic.jpg'"); }
__________________
Ali Inhan
Turkish graphic and web designer
an Apple fan
www.aliinhan.com
inhan is offline   Reply With Quote
Old 08-13-2005, 11:10 PM   #4
inhan
it's all about patience
 
inhan's Avatar
 
Join Date: Jun 2005
Location: istanbul
Posts: 5,859
Default

Sorry, the one i wrote was for changing background image. The right code for the button (only the button, no scripting elsewhere) is:
ActionScript Code:
on (release) {     getURL("javascript:document.bgColor='#six_digit_color_code"); }
Here I've put some the codes:
http://www.aliinhan.com/sources/JScodes.html
__________________
Ali Inhan
Turkish graphic and web designer
an Apple fan
www.aliinhan.com

Last edited by inhan; 08-14-2005 at 05:53 PM..
inhan is offline   Reply With Quote
Old 08-29-2005, 09:45 PM   #5
Spiritmonger
Registered User
 
Join Date: Aug 2005
Posts: 1
Arrow Great Post !!!



Perfect and simple script

Thanks inhan, its was helpfull for me too !

Cheers
Spiritmonger is offline   Reply With Quote
Old 08-30-2005, 12:55 PM   #6
inhan
it's all about patience
 
inhan's Avatar
 
Join Date: Jun 2005
Location: istanbul
Posts: 5,859
Default

anytime
__________________
Ali Inhan
Turkish graphic and web designer
an Apple fan
www.aliinhan.com
inhan is offline   Reply With Quote
Old 02-15-2007, 03:27 PM   #7
aksands
Registered User
 
Join Date: Feb 2007
Posts: 3
Default

Changing the bg Image of my HTML via Flash is exactly what I want to do! Thank you for providing this script!

I've included the script provided by Inhan...but I'm not getting the expected results.

Please forgive me, but I am not experienced with javascript. Do i need to put a javascript function in my HTML for this to work?
aksands is offline   Reply With Quote
Old 02-15-2007, 03:33 PM   #8
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
Default

How about this page??? Don't know about changing the background image, but you should be able to use the similar approach to do so...

http://tutorials.flashvacuum.com/ind...ckground_Color
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 02-15-2007, 06:00 PM   #9
aksands
Registered User
 
Join Date: Feb 2007
Posts: 3
Default

what would I change in this function to make it change the background image instead of the color?

function changeBgColor(newBgColor) {
if (window.document && window.document.bgColor) {
document.bgColor = newBgColor;
}
}

Thank you!!!
aksands is offline   Reply With Quote
Old 02-15-2007, 09:54 PM   #10
inhan
it's all about patience
 
inhan's Avatar
 
Join Date: Jun 2005
Location: istanbul
Posts: 5,859
Default

I'm not sure if it would work on PC's too, but I modified the code and it works with Mac FF & Safari. If you want the image not to repeat, you have to add something to the code (with which I am not familiar).

In the html file, in the "head" section:
HTML Code:
<script language="JavaScript">
<!--
function changeBgImg(newBgImg) {
	//alert('new image is = ' + newBgImg);
	document.body.background = newBgImg 
}
-->
</script>
In the flash file:
ActionScript Code:
bgImgages = new Array("1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"); for (var i = 0; i<bgImgages.length; i++) {     this["color"+i+"_btn"].id = i;     this["color"+i+"_btn"].onRelease = function() {         getURL("javascript:changeBgImg('images/"+bgImgages[this.id]+"')");     }; }
__________________
Ali Inhan
Turkish graphic and web designer
an Apple fan
www.aliinhan.com
inhan is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:19 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.