A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Browser window shake

  1. #1
    Junior Member
    Join Date
    Aug 2001
    Posts
    4
    I have created a short explosion movie. As the user clicks a button it starts a short sequence where the explosion happens. What I want to do is get the whole browser window to shake as the explosion happens.

    I have seen this effect on some HTML sites, when the user rolls over a button but is it possible to trigger from a flash movie in an HTML web page?


  2. #2
    rebmeM roineS
    Join Date
    Dec 2000
    Location
    between my ears
    Posts
    150
    Originally posted by JonTowers
    I have created a short explosion movie. As the user clicks a button it starts a short sequence where the explosion happens. What I want to do is get the whole browser window to shake as the explosion happens.

    I have seen this effect on some HTML sites, when the user rolls over a button but is it possible to trigger from a flash movie in an HTML web page?

    i believe this has to take place on window load but here is the code: (but i think at the end of this code it tells you how to attach to button) hope this helps, later.

    zeb00

    The three functions are
    shake_xy(n) : Shakes the screen in x and y directions, n is a size number, bigger means more shaking!
    shake_x(n) : Shakes the screen in the x direction!
    shake_y(n) : Shakes the screen in the y direction!
    Insert the following code into your HTML page

    <SCRIPT LANGUAGE="JavaScript1.2">
    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->
    <!-- Modified by Flash kit http://www.flashkit.com -->
    function shake_xy(n) {
    if (self.moveBy) {
    for (i = 10; i > 0; i--) {
    for (j = n; j > 0; j--) {
    self.moveBy(0,i);
    self.moveBy(i,0);
    self.moveBy(0,-i);
    self.moveBy(-i,0);
    }
    }
    }
    }
    function shake_x(n) {
    if (self.moveBy) {
    for (i = 10; i > 0; i--) {
    for (j = n; j > 0; j--) {
    self.moveBy(i,0);
    self.moveBy(-i,0);
    }
    }
    }
    }
    function shake_y(n) {
    if (self.moveBy) {
    for (i = 10; i > 0; i--) {
    for (j = n; j > 0; j--) {
    self.moveBy(0,i);
    self.moveBy(0,-i);
    }
    }
    }
    }
    //-->
    </SCRIPT>



    To call from HTML use call the javascript shake functions described above, either using an


    <A HREF = "javascript:shake_xy(3)">Shake XY</A>

    -------------------------------PART II
    Here's the code:

    and a call in Flash would look like:
    getURL ("javascript:shake_xy(10,10);", _self)

    Enjoy!

    within a normal link, or as a javascript event in a button


    <INPUT TYPE=BUTTON value="Shake x" onClick="shake_x(4)">

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