JavaScript animation doesn't work

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Reid Goldsborough

    JavaScript animation doesn't work

    Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation,
    with one coin (tet) morphing into another. The code doesn't work.
    Anybody feel like taking a shot at correcting me? It's short. Here it
    is:

    <HTML>

    <HEAD>
    <TITLE>Thraci an tetradrachm animation</TITLE>

    <SCRIPT LANGUAGE="JavaS cript">
    <!-- begin script
    tetSeries = new Array("tet00.jp g", "tet01.jpg" , "tet02.jpg" ,
    "tet03.jpg" , "tet04.jpg" , "tet05.jpg" , "tet06.jpg" ,

    "tet07.jpg" , "tet08.jpg" , "tet09.jpg" );
    imagesCache = new Array ()
    for (i=0;i<tetSerie s.length;i++) {
    imagesCache[i] = new Image;
    imagesCache[i].src = tetSeries[i]
    }
    theCount = 0;
    function turnPage() {
    if(theCount == imagesCache.len gth-1)
    {
    theCount = 0
    } else {
    theCount++
    }
    document.tet.sr c = imagesCache[theCount].src;
    setTimeout("tur nPage()", 300);
    // end script -->
    </SCRIPT>

    </HEAD>

    <BODY>

    <img name="tet" src="tet00.jpg" width="372" height="365" border="0"
    alt="Tet images">

    <body bgcolor="#FFFFF F"onload="turnP age()">

    </BODY>

    </HTML>

    Thanks.

    --

    Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
    Glomming: Coin Connoisseurship : http://rg.ancients.info/glom
    Bogos: Counterfeit Coins: http://rg.ancients.info/bogos
  • Erwin Moller

    #2
    Re: JavaScript animation doesn't work

    Reid Goldsborough wrote:

    Hi reid, You have been sloppy.
    Read on, but please note that opening your Javascriptconso le in your own
    browser gives you the errors too....

    Before you post a JS-question, first check your own JS-console for obvious
    errors..
    [color=blue]
    > Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation,
    > with one coin (tet) morphing into another. The code doesn't work.
    > Anybody feel like taking a shot at correcting me? It's short. Here it
    > is:
    >
    > <HTML>
    >
    > <HEAD>
    > <TITLE>Thraci an tetradrachm animation</TITLE>
    >
    > <SCRIPT LANGUAGE="JavaS cript">
    > <!-- begin script
    > tetSeries = new Array("tet00.jp g", "tet01.jpg" , "tet02.jpg" ,
    > "tet03.jpg" , "tet04.jpg" , "tet05.jpg" , "tet06.jpg" ,
    >
    > "tet07.jpg" , "tet08.jpg" , "tet09.jpg" );
    > imagesCache = new Array ()
    > for (i=0;i<tetSerie s.length;i++) {
    > imagesCache[i] = new Image;
    > imagesCache[i].src = tetSeries[i]
    > }
    > theCount = 0;
    > function turnPage() {
    > if(theCount == imagesCache.len gth-1)
    > {
    > theCount = 0
    > } else {
    > theCount++
    > }
    > document.tet.sr c = imagesCache[theCount].src;
    > setTimeout("tur nPage()", 300);[/color]

    what about closing your function here??
    [color=blue]
    > // end script -->
    > </SCRIPT>
    >
    > </HEAD>
    >
    > <BODY>
    >
    > <img name="tet" src="tet00.jpg" width="372" height="365" border="0"
    > alt="Tet images">
    >
    > <body bgcolor="#FFFFF F"onload="turnP age()">
    >
    > </BODY>
    >
    > </HTML>
    >
    > Thanks.
    >
    > --
    >
    > Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
    > Glomming: Coin Connoisseurship : http://rg.ancients.info/glom
    > Bogos: Counterfeit Coins: http://rg.ancients.info/bogos[/color]

    Comment

    • Reid Goldsborough

      #3
      Re: JavaScript animation doesn't work

      On Thu, 11 Sep 2003 14:50:20 +0200, Erwin Moller
      <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote:
      [color=blue]
      >Hi reid, You have been sloppy.[/color]

      Thanks for your kind words.
      [color=blue]
      >Read on, but please note that opening your Javascriptconso le in your own
      >browser gives you the errors too....[/color]
      [color=blue]
      >Before you post a JS-question, first check your own JS-console for obvious
      >errors..[/color]

      I don't have a JS-console or any other console, that I know of. I'm
      using Notepad to edit code that was suggested in an article I read. As
      I said, I'm a neophyte here. I don't have an interest in learning
      JavaScript. I know I should, that this is the "proper" way to go.
      [color=blue][color=green]
      >> Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation,
      >> with one coin (tet) morphing into another. The code doesn't work.
      >> Anybody feel like taking a shot at correcting me? It's short. Here it
      >> is:
      >>
      >> <HTML>
      >>
      >> <HEAD>
      >> <TITLE>Thraci an tetradrachm animation</TITLE>
      >>
      >> <SCRIPT LANGUAGE="JavaS cript">
      >> <!-- begin script
      >> tetSeries = new Array("tet00.jp g", "tet01.jpg" , "tet02.jpg" ,
      >> "tet03.jpg" , "tet04.jpg" , "tet05.jpg" , "tet06.jpg" ,
      >>
      >> "tet07.jpg" , "tet08.jpg" , "tet09.jpg" );
      >> imagesCache = new Array ()
      >> for (i=0;i<tetSerie s.length;i++) {
      >> imagesCache[i] = new Image;
      >> imagesCache[i].src = tetSeries[i]
      >> }
      >> theCount = 0;
      >> function turnPage() {
      >> if(theCount == imagesCache.len gth-1)
      >> {
      >> theCount = 0
      >> } else {
      >> theCount++
      >> }
      >> document.tet.sr c = imagesCache[theCount].src;
      >> setTimeout("tur nPage()", 300);[/color]
      >
      >what about closing your function here??[/color]

      I don't know what this means. And a Google search just now didn't
      reveal anything useful as to what exactly this means, how I should
      close my function.

      --

      Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
      Glomming: Coin Connoisseurship : http://rg.ancients.info/glom
      Bogos: Counterfeit Coins: http://rg.ancients.info/bogos

      Comment

      • Erwin Moller

        #4
        Re: JavaScript animation doesn't work

        Reid Goldsborough wrote:
        [color=blue]
        > On Thu, 11 Sep 2003 14:50:20 +0200, Erwin Moller
        > <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote:
        >[color=green]
        >>Hi reid, You have been sloppy.[/color]
        >
        > Thanks for your kind words.[/color]

        Hi Reid,

        I don't want to insult you but you were sloppy.
        :-/
        [color=blue]
        >[color=green]
        >>Read on, but please note that opening your Javascriptconso le in your own
        >>browser gives you the errors too....[/color]
        >[color=green]
        >>Before you post a JS-question, first check your own JS-console for obvious
        >>errors..[/color]
        >
        > I don't have a JS-console or any other console, that I know of. I'm
        > using Notepad to edit code that was suggested in an article I read. As
        > I said, I'm a neophyte here. I don't have an interest in learning
        > JavaScript. I know I should, that this is the "proper" way to go.[/color]

        Okay, go download a browser, IE-explorer, Mozilla, whatever suits your
        needs.
        Under Mozilla (and Netscape) under Tools-menu --> webdevelopment -->
        Javascript Console.

        Under IE, you'll have to figure it out yourself, but I am sure they have it
        too.

        That console is your friend.
        Use it always when something happens that you don't understand.
        [color=blue]
        >[color=green][color=darkred]
        >>> Hi. I'm a JavaScript neophyte. I'm trying to create a JPEG animation,
        >>> with one coin (tet) morphing into another. The code doesn't work.
        >>> Anybody feel like taking a shot at correcting me? It's short. Here it
        >>> is:
        >>>
        >>> <HTML>
        >>>
        >>> <HEAD>
        >>> <TITLE>Thraci an tetradrachm animation</TITLE>
        >>>
        >>> <SCRIPT LANGUAGE="JavaS cript">
        >>> <!-- begin script
        >>> tetSeries = new Array("tet00.jp g", "tet01.jpg" , "tet02.jpg" ,
        >>> "tet03.jpg" , "tet04.jpg" , "tet05.jpg" , "tet06.jpg" ,
        >>>
        >>> "tet07.jpg" , "tet08.jpg" , "tet09.jpg" );
        >>> imagesCache = new Array ()
        >>> for (i=0;i<tetSerie s.length;i++) {
        >>> imagesCache[i] = new Image;
        >>> imagesCache[i].src = tetSeries[i]
        >>> }
        >>> theCount = 0;
        >>> function turnPage() {
        >>> if(theCount == imagesCache.len gth-1)
        >>> {
        >>> theCount = 0
        >>> } else {
        >>> theCount++
        >>> }
        >>> document.tet.sr c = imagesCache[theCount].src;
        >>> setTimeout("tur nPage()", 300);[/color]
        >>
        >>what about closing your function here??[/color]
        >
        > I don't know what this means. And a Google search just now didn't
        > reveal anything useful as to what exactly this means, how I should
        > close my function.[/color]

        Your function called turnPage is never closed.

        It should be like this:
        function turnPage(){
        // your code
        // more code
        }

        Watch the closing }
        So the one after turnPage() { is for opening.
        And it should always have a corresponding }

        Good luck.

        I checked your function, but it works.

        Regards,
        Erwin
        [color=blue]
        >
        > --
        >
        > Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
        > Glomming: Coin Connoisseurship : http://rg.ancients.info/glom
        > Bogos: Counterfeit Coins: http://rg.ancients.info/bogos[/color]

        Comment

        • Reid Goldsborough

          #5
          Re: JavaScript animation doesn't work

          On Fri, 12 Sep 2003 10:51:53 +0200, Erwin Moller
          <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote:
          [color=blue]
          >I don't want to insult you but you were sloppy.[/color]

          OK, I'm sloppy. I think I'm new to this and know very little about it
          and tried to carefully follow the directions in this magazine article
          I read, but if you say I'm sloppy, I have no problem with this.

          Here's a question that you, being an expert and not sloppy, may know
          the answer to. How do I place this JavaScript code within a page
          rather than, as I did, have a new page for it? Here's the code again,
          this time with the function closed as you suggested before, which made
          it work:

          <HTML>
          <HEAD>
          <META NAME="Author" Content="Reid Goldsborough">
          <TITLE>Thraci an tetradrachm animation</TITLE>
          <SCRIPT LANGUAGE="JavaS cript">
          tetSeries = new Array("tet00.jp g", "tet01.jpg" , "tet02.jpg" ,
          "tet03.jpg" , "tet04.jpg" , "tet05.jpg" , "tet06.jpg" , "tet07.jpg" ,
          "tet08.jpg" , "tet09.jpg" , "tet09.jpg" , "tet09.jpg" );
          imagesCache = new Array ()
          for (i=0;i<tetSerie s.length;i++) {
          imagesCache[i] = new Image;
          imagesCache[i].src = tetSeries[i]
          }
          theCount = 0;
          function turnPage() {
          if(theCount == imagesCache.len gth-1)
          {
          theCount = 0
          } else {
          theCount++
          }
          document.tet.sr c = imagesCache[theCount].src;
          setTimeout("tur nPage()", 600);
          }
          </SCRIPT>
          </HEAD>
          <BODY bgcolor="#FFFFF F"onload="turnP age()">
          <CENTER>
          <img name="tet" src="tet00.jpg" width="372" height="365" border="0"
          alt="Tet animation">
          </CENTER>
          </BODY>
          </HTML>

          I tried placing some of this code into the body of the page but
          couldn't get the animation to work.

          --

          Coin Collecting: Consumer Guide: http://rg.ancients.info/guide
          Glomming: Coin Connoisseurship : http://rg.ancients.info/glom
          Bogos: Counterfeit Coins: http://rg.ancients.info/bogos

          Comment

          • Albert Wagner

            #6
            Re: JavaScript animation doesn't work

            On Sat, 13 Sep 2003 15:25:18 -0400
            Reid Goldsborough <reidgold@netax s.com> wrote:
            <snip>

            Hi, Reid. I'm just a newbie on the animation stuff, but your code works
            fine on my box with Opera 7.11. The only change I had to make was to
            access a set of images here:

            tetSeries = new Array("droep0.g if",...

            imagesCache[i].src = "../images/droep/" + tetSeries[i];

            Are you sure that your images are in the same directory as the html?

            --
            Don't you see that the whole aim of Newspeak is to narrow the range of
            thought? In the end we shall make thoughtcrime literally impossible,
            because there will be no words in which to express it.
            -- George Orwell, 1984

            Comment

            • Erwin Moller

              #7
              Re: JavaScript animation doesn't work

              Reid Goldsborough wrote:
              [color=blue]
              > On Fri, 12 Sep 2003 10:51:53 +0200, Erwin Moller
              > <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote:
              >[color=green]
              >>I don't want to insult you but you were sloppy.[/color]
              >
              > OK, I'm sloppy. I think I'm new to this and know very little about it
              > and tried to carefully follow the directions in this magazine article
              > I read, but if you say I'm sloppy, I have no problem with this.
              >[/color]

              Hi Reid,

              So I did insult you. Sorry man, but relax.

              One can make many mistakes in code, ranging from just a typo in a
              variablename to a very subtle fault in some recursive function.

              Not closing a function is just sloppy. I am not saying you are sloppy or
              your are not smart, I just say the code you send was sloppy. Do not take
              that personally.
              Example: My english is sloppy, I know that. It is not my mothertongue. If
              somebody corrects me and says I am sloppy, I just take that as an
              informative correction, not personal.

              Back to the subject, allright?
              [color=blue]
              > Here's a question that you, being an expert and not sloppy, may know
              > the answer to.[/color]

              Give it a rest now, Reid. ;-)

              [color=blue]
              > How do I place this JavaScript code within a page
              > rather than, as I did, have a new page for it? Here's the code again,
              > this time with the function closed as you suggested before, which made
              > it work:[/color]

              Ok.
              So your code works on this (example)page?
              Then it will work in another page too.
              Just be sure that:
              1) Your imagename in the image-tag in your page corresponds with the one you
              use in your function.
              2) Be sure that the images can be found. It is relative from the the path
              where the page resides.
              [color=blue]
              >
              > <HTML>
              > <HEAD>
              > <META NAME="Author" Content="Reid Goldsborough">
              > <TITLE>Thraci an tetradrachm animation</TITLE>
              > <SCRIPT LANGUAGE="JavaS cript">
              > tetSeries = new Array("tet00.jp g", "tet01.jpg" , "tet02.jpg" ,
              > "tet03.jpg" , "tet04.jpg" , "tet05.jpg" , "tet06.jpg" , "tet07.jpg" ,
              > "tet08.jpg" , "tet09.jpg" , "tet09.jpg" , "tet09.jpg" );
              > imagesCache = new Array ()
              > for (i=0;i<tetSerie s.length;i++) {
              > imagesCache[i] = new Image;
              > imagesCache[i].src = tetSeries[i]
              > }
              > theCount = 0;
              > function turnPage() {
              > if(theCount == imagesCache.len gth-1)
              > {
              > theCount = 0
              > } else {
              > theCount++
              > }
              > document.tet.sr c = imagesCache[theCount].src;
              > setTimeout("tur nPage()", 600);
              > }
              > </SCRIPT>
              > </HEAD>
              > <BODY bgcolor="#FFFFF F"onload="turnP age()">[/color]


              This is wrong. It should be:
              <BODY bgcolor="#FFFFF F" onload="turnPag e()">

              with a space before the onLoad="turnPag e()"
              ANd I think it should be onLoad instead of onload, with a capital L.
              I am not sure which browsers will forgive it, better try to spell it
              correct. :-)

              [color=blue]
              > <CENTER>
              > <img name="tet" src="tet00.jpg" width="372" height="365" border="0"
              > alt="Tet animation">
              > </CENTER>
              > </BODY>
              > </HTML>
              >
              > I tried placing some of this code into the body of the page but
              > couldn't get the animation to work.
              >[/color]


              Comment

              Working...