A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: change html background from flash

  1. #1
    Member
    Join Date
    Sep 2000
    Location
    porto
    Posts
    74

    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

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    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

  3. #3
    Member
    Join Date
    Sep 2000
    Location
    porto
    Posts
    74
    mint!

    exactley what i wanted

    thanks

    james
    drag&drop

    ps. if your interested the project is at http://www.drag-drop.net/portfolio

  4. #4
    Member
    Join Date
    Sep 2000
    Location
    porto
    Posts
    74
    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

  5. #5
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center