Results 1 to 3 of 3

Thread: flying plane script speed and positioning

  1. #1
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default flying plane script speed and positioning

    1) Script Title: flying plane script

    2) Script URL (on DD): http://dynamicdrive.com/dynamicindex4/plane.htm

    3) Describe problem:
    1. i have problem with the speed, how to set it at the exact speed, '100', '200', etc. Because now everything is random.
    2. i want to set position at the header only like the screenshot, but know it fly all around the page.


    Thank you so much
    Last edited by davelf; 02-22-2012 at 03:23 AM. Reason: The Problem solved by Vic
    _____________________

    David Demetrius // davejob
    _____________________

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <style type="text/css">
    /*<![CDATA[*/
    
    #plane {
      position:absolute;z-Index:101;left:0px;top:50px;width:100%;height:50px;
    }
    
    #plane IMG {
      position:absolute;left:100px;top:0px;width:100px;height:50px;
    }
    
    #plane2 {
      position:absolute;z-Index:101;left:0px;top:250px;width:100%;height:50px;
    }
    
    #plane2 IMG {
      position:absolute;left:100px;top:0px;width:100px;height:50px;
    }
    
    /*]]>*/
    </style></head>
    
    <body>
    <div id="plane" >
     <img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" alt="plane" width="100" height="50" />
    </div>
    
    <div id="plane2" >
     <img src="http://www.vicsjavascripts.org.uk/StdImages/Two.gif" alt="plane" width="100" height="50" />
    </div>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    var fly={
    
     init:function(id,i){
      var oop=obj=document.getElementById(id),img=obj.getElementsByTagName('IMG')[0],w=img.width;
      obj.style.visibility='hidden';
      obj.style.overflow='hidden';
      img.style.visibility='visible';
      img.style.left=-w+'px';
      this[id]={
       obj:obj,
       img:img,
       srt:-w,
       lft:-w,
       i:typeof(i)=='number'?i:5
      }
      setInterval(function(){ fly.fly(id); },50);
     },
    
     fly:function(id){
      var oop=this[id];
      oop.lft+=oop.i;
      if (oop.lft>oop.obj.offsetWidth){
       oop.lft=oop.srt;
      }
      oop.img.style.left=oop.lft+'px';
    
     }
    
    }
    
    fly.init('plane',5);
    fly.init('plane2',2);
    /*]]>*/
    </script>
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    davelf (02-22-2012)

  4. #3
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default

    @Vic You're the best
    _____________________

    David Demetrius // davejob
    _____________________

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
  •