Can Somebody Check This?

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

    Can Somebody Check This?

    I'm trying to create a script that will cycle through a bunch of pics
    (1.jpg, 2.jpg, and so on up to 429.jpg) to make a movie. However, I
    can't get it to work. Could someone tell me what I'm doing wrong?
    Here it is...

    <html>

    <head>

    <script>
    pics = new Array()
    curPic = 0

    preLoad() {
    for (i=0; i <= 429; i++) {
    pics[i] = new Image()
    pics[i].src = i + ".jpg"
    }
    }

    dispPic() {
    document.images['moviePic'].src = curPic + ".jpg"
    curPic++
    setTimeout("dis pPic()", 20)
    }
    </script>

    </head>

    <body>

    <body onload="preLoad (); dispPic()">

    <img src="1.jpg" name="moviePic" width="640" height="416">

    </body>

    </html>
  • Evertjan.

    #2
    Re: Can Somebody Check This?

    chris wrote on 03 mei 2004 in comp.lang.javas cript:
    [color=blue]
    > <html>
    >
    > <head>
    >
    > <script>
    > pics = new Array()
    > curPic = 0
    >
    > preLoad() {
    > for (i=0; i <= 429; i++) {
    > pics[i] = new Image()
    > pics[i].src = i + ".jpg"
    > }
    >}
    >
    > dispPic() {
    > document.images['moviePic'].src = curPic + ".jpg"
    > curPic++
    > setTimeout("dis pPic()", 20)
    >}
    > </script>
    >
    > </head>
    >
    > <body>
    >
    > <body onload="preLoad (); dispPic()">
    >
    > <img src="1.jpg" name="moviePic" width="640" height="416">
    >
    > </body>
    >
    > </html>[/color]

    Functions are declared with the word "function"
    Preloading should be done BEFORE the onload=""
    20 ms could be to short for some systems

    [declare script type]
    [use the preloaded entity]
    [declare curPic with a var.]
    [No double <body>]
    [declare "px" in sizes]


    <html>
    <head>
    <script type="text/javascript">
    var pics = new Array()
    var curPic = 0

    for (i=0; i <= 429; i++) {
    pics[i] = new Image()
    pics[i].src = i + ".jpg"
    }

    function dispPic() {
    document.images['moviePic'].src = pics[curPic++].src
    setTimeout("dis pPic()", 20)
    }
    </script>
    </head>
    <body onload="dispPic ()">
    <img src="1.jpg" name="moviePic" width="640px" height="416px">
    </body>
    </html>

    not tested, btw.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Ivo

      #3
      Re: Can Somebody Check This?

      "Evertjan." wrote[color=blue]
      > [declare "px" in sizes]
      > <img src="1.jpg" name="moviePic" width="640px" height="416px">[/color]

      First time I 've seen units declared in simple width and height attributes.
      Are you not confused with widths and heights coming from css? But I tried
      and found it works (tested in IE6)!
      How far backward compatible is this? I 'm sure this wasn't necessary before.
      Ivo


      Comment

      • Michael Winter

        #4
        Re: Can Somebody Check This?

        On Tue, 4 May 2004 13:31:06 +0200, Ivo <no@thank.you > wrote:
        [color=blue]
        > "Evertjan." wrote
        >[color=green]
        >> [declare "px" in sizes]
        >> <img src="1.jpg" name="moviePic" width="640px" height="416px">[/color]
        >
        > First time I 've seen units declared in simple width and height
        > attributes.
        > Are you not confused with widths and heights coming from css? But I
        > tried and found it works (tested in IE6)!
        > How far backward compatible is this? I 'm sure this wasn't necessary
        > before.[/color]

        You are correct: it wasn't and isn't necessary. In fact, I believe it's
        erroneous.

        The width and height attributes for the IMG element are of type "Length".
        Length may either be a "Pixel" value or a percentage. Therefore,
        width="640" is automatically stating 640 pixels. No units are necessary,
        and are probably incorrect if used.

        Mike

        --
        Michael Winter
        M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

        Comment

        • Mick White

          #5
          Re: Can Somebody Check This?

          Evertjan. wrote:
          [color=blue]
          > function dispPic() {
          > document.images['moviePic'].src = pics[curPic++].src
          > setTimeout("dis pPic()", 20)
          > }
          > </script>
          > </head>[/color]

          What happens when you reach 429?
          Mick

          Comment

          • Michael Daly

            #6
            Re: Can Somebody Check This?

            On 4-May-2004, Michael Winter <M.Winter@bluey onder.co.invali d> wrote:
            [color=blue]
            > width="640" is automatically stating 640 pixels. No units are necessary,
            > and are probably incorrect if used.[/color]

            Specifying the default in most languages is rarely incorrect even if unnecessary.
            It just helps to make the information very specific. HTML and its variants
            specify that "px" is a legitimate qualifier; why should it be incorrect to use it?

            Mike

            Comment

            • Lasse Reichstein Nielsen

              #7
              Re: Can Somebody Check This?

              "Michael Daly" <michaelDaly@fo o.bar> writes:
              [color=blue]
              > On 4-May-2004, Michael Winter <M.Winter@bluey onder.co.invali d> wrote:
              >[color=green]
              >> width="640" is automatically stating 640 pixels. No units are necessary,
              >> and are probably incorrect if used.[/color][/color]

              ....[color=blue]
              > HTML and its variants specify that "px" is a legitimate qualifier;
              > why should it be incorrect to use it?[/color]

              No it doesn't.
              <URL:http://www.w3.org/TR/html4/types.html#h-6.6>
              The valid values of an HTML length is either pixels (a plain number) or
              percentages (a number with "%" after).

              Units like "px" are CSS, not HTML. You can use them in they style tag,
              but that is CSS content. It should not be used in the width property
              (but one should use CSS instead of the width property in any case -
              it's even deprecated on HR, TD, TH, and PRE elements).

              /L
              --
              Lasse Reichstein Nielsen - lrn@hotpop.com
              DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
              'Faith without judgement merely degrades the spirit divine.'

              Comment

              • Michael Daly

                #8
                Re: Can Somebody Check This?

                On 4-May-2004, wrote:
                [color=blue]
                > Units like "px" are CSS, not HTML.[/color]

                You're right - I stand corrected. What a Babel we've got here!

                Mike

                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: Can Somebody Check This?

                  Ivo wrote:
                  [color=blue]
                  > "Evertjan." wrote[color=green]
                  >> [declare "px" in sizes]
                  >> <img src="1.jpg" name="moviePic" width="640px" height="416px">[/color]
                  >
                  > First time I 've seen units declared in simple width and height attributes.
                  > Are you not confused with widths and heights coming from css? But I tried
                  > and found it works (tested in IE6)![/color]

                  That's one of the Bad Things about IE for developers:
                  It turns every sh*t into gold.
                  [color=blue]
                  > How far backward compatible is this?
                  > I 'm sure this wasn't necessary before.[/color]

                  It is worng, simple as that.


                  PointedEars

                  Comment

                  Working...