Results 1 to 6 of 6

Thread: Own company truck image driving across page

  1. #1
    Join Date
    Sep 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile Own company truck image driving across page

    I have a picture of my company truck, I am looking for a script that when you access my site, the truck drives across the page. ANy one know where I can find this, or how is it done?
    thanks in advance

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Hope this basic example helps:
    Code:
    <script type="text/javascript">
    var i=10; //  Initial value of the image
    function move()
    {
    var speed=200, // Speed of the movement. The larger the value, the lower the speed. 
    el=document.getElementById('myimage'), // ID of the image
    direction='left'; // Direction of image. Values could either be left or right
    
    //////////// No need to edit beyond this part
    el.style.position='relative';
    (direction==='left')?el.style.left=i+'px':el.style.right=i+'px';
    i+=10;
    setTimeout('move()',speed);
    }
    window.onload=move;
    </script>
    <img src="http://rangana.moonylist.com/images/Picture1.jpg" alt="Image1" id="myimage">
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Why are you increasing the variable by 30? Also, you should either have it stop, dissapear, or rever directions if it reaches the end of the page.
    Jeremy | jfein.net

  4. #4
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    I'm not increasing the variable by 30.

    I'm incrementing i variable by 10.

    My example is not perfect, it's just basic, so there's flaw on it, and that's where comes the OP's learning curb.

    Hope that makes sense to you Nile.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  5. #5
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Yes, rangana. My mistake, I was playing around with your example, and I made it increase by 30.
    Jeremy | jfein.net

  6. #6
    Join Date
    Sep 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thanks guys, as soon as I get my graphic perfect, I'll try the script.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •