A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: trying to add javascripting "shake"...can't do it.

  1. #1
    Senior Member
    Join Date
    Feb 2001
    Posts
    121
    I am trying to shake the browser window using javascripting. I can't seem to get it to work though. I go to the pulldown menu and select javascripting. I then paste the code. when played, either in stand alone or browser it doesn't work. Where am I going wrong?

    chad

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    What is the javascript you are using?

    You relize that most shake scripts require some of the javascript to be in the html itself.

    post the script and we'll have a look at it.

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    Okay, This is what goes into the Javascript Box shake_xy(n)

    Now this must be in your HTML in between the <head> and </head> tags:

    <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>

    You will have to edit the HTML in a text editor or a HTML editor that does not change your code.

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    I looked at your file and you do not have any html on the page- that is your problem...

    Also Javascript cannot be used in standalones or when your SWF is embedded into another app using OLE and Flash.OCX. Javascript only works with a Javscript/ Ecma enabled device (AKA a Web Browser) which FlashPLA.EXE or any projector created with it most defianatly is not.

    This where you would use FS Commands. Projectors are limmeted since they only have a handful of built in commands and without creating a new enhanced projector (It has been Done- FlASHANTS FMProjector and SWF Studio projectors are enhanced) that is all you will have access to.

    When you Embed Flash into VB, C++, or Java (it can be done) then you use FS Commands to Pass a variable and a value to Live Connect (Java) or Active X (VB typically). You must program your app to "catch" these variables from Active X or Live Connect and act on them.

  5. #5
    Senior Member
    Join Date
    Feb 2001
    Posts
    121
    Ok, I was doing it the other way around. I put the long code in the js window.

    thanks

    Chad

  6. #6
    Senior Member
    Join Date
    Feb 2001
    Posts
    121
    here is the html as it appears on my computer.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    <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>

    </HEAD>
    <BODY BGCOLOR="#000000">
    <CENTER>
    <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" id=breakup width=700 height=400 codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0">
    <param name="movie" value="breakup.swf">
    <param name="quality" value="high">
    <param name="play" value="true">
    <param name="loop" value="true">
    <param name="bgcolor" value="#000000">
    <SCRIPT LANGUAGE=JavaScript>
    <!--
    var ShockMode = 0;
    if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
    if (navigator.plugins && navigator.plugins["Shockwave Flash"])
    ShockMode = 1;
    } if (ShockMode ) {
    document.write('<embed src="breakup.swf"');
    document.write(' width=700 height=400 bgcolor="#000000" quality="high" loop="true"');
    document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/">');
    document.write('</EMBED>');
    } else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)) { document.write('<IMG SRC="nonflash.gif" width=700 height=400>');
    }
    //-->
    </SCRIPT><NOEMBED><IMG SRC="nonflash.gif" width=700 height=400 BORDER=0></NOEMBED><NOSCRIPT><IMG SRC="nonflash.gif" width=700 height=400 BORDER=0></NOSCRIPT></OBJECT>
    </CENTER>
    </BODY>
    </HTML>

    this is the code for the shaking and the flash movie. Now, In the movie in the JS box, i have this

    shake_xy(n)

    It still does not work. Why?? Am I missing something? It seems as if this would be so simple. yet I still can't get it to work. I would like to send you the .fun file then you fix it, and send it back to me. then I can 'reverse engineer
    what you did to make it work.

    Chad

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