Setting browser background to change at specific frame.
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Setting browser background to change at specific frame.

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    5

    Setting browser background to change at specific frame.

    Hello,

    I finished working on my stage and now i need to apply a background image that will appear under the flash swf.

    Now I know that in the HTML, instead of the color I can just link to my image via background url BUT I need this image to change at a specific time to coincide with the color change in my flash swf.
    Basically there is image1 at website startup and after for example 25 frames it becomes image2 and stops there


    Hope this makes sense.

    Thank you

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    El Paso
    Posts
    2,429
    This will require a combination of CSS, javascript and as3.

    You can communicate with your surrounding environment via as3's ExternalInterface class. Read more on it here.
    http://help.adobe.com/en_US/FlashPla...Interface.html

    Sorry I don't have time to verify the exact code but will look something like this.
    You'll have a javascript function waiting to be called by your swf which will modify the css

    So just before the end of you <head></head> tag you'd have

    Code:
    <script>
    function changeBackground(myImg){
      document.body.style.background="background-image: url(' + myImg + ') no-repeat";
    }
    </script>
    Then somewhere in your as3 you'd have
    Code:
    ExternalInterface.call("changeBackground", "image1.jpg");

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

Poll by Flashkit.com