Results 1 to 2 of 2

Thread: moving objects..

  1. #1
    gencoglu
    Guest

    Lightbulb moving objects..

    Hello
    Using VB I can make a butterfly move/fly..an"openwinged..a closedwinged" then they fly...My question is that How can do the same using" java script"Can we make things move/fly to all directions. in JavaScript"
    thanks

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Yes, you can. Heres some sample code which I use to get and set positions of objects in an HTML document.

    Heres an example of how to use it.

    Code:
    <div id="image1.gif" onmouseover="findDom('image1').style.left=findleft('image1')-10"><img src="image1.gif"></div>
    Whar happens is when you move the mouse over the image it moves it 10 pixels to the left. You can replace left with top.

    Code:
    function findleft(objectID){
      if (findDom(objectID).left){return findDom(grandfather).left;}
      if (findDom(objectID).pixelLeft){return findDom(grandfather).pixelLeft;}
      if (findDom(objectID).offsetLeft){return findDom(grandfather).offsetLeft;}
      return 'null';
    }
    
    function findtop(objectID){
      if (findDom(objectID).top){return findDom(grandfather).top;}
      if (findDom(objectID).pixelTop){return findDom(objectID).pixelTop;}
      if (findDom(objectID).offsetTop){return findDom(objectID).offsetTop;}
      return 'null';
    }
    
    function findDom(objectID){
      if (document.all){
       return document.all(objectID);
      } else if (document.getElementById){
       return document.getElementById(objectID);
      } else if (document.layers){
       return (document.layers[objectID]);
      }
    }
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

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