A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Javascript help

  1. #1
    Junior Member
    Join Date
    Apr 2007
    Posts
    2

    Javascript help

    Hello all
    i need some help with this program that i'm trying to make

    i'm new at this so it's probably a dumb mistake but i can't find it

    function Bereken_onclick()
    {
    horizontalspeed = prompt("Give the horizontal speed in meters per second","")
    height = prompt("Give the height of the plane in meters.","")
    verticalspeed = (height*2*9.81)^0.5
    distance = (horizontalspeed*verticalspeed)/9.81
    tg = height / distance
    arctangens = Atn(tg)
    angle = 60*arctangens
    document.write("The pilot has to drop the bomb when he sees the target under an angle of " + angle + " degrees.")
    }

    and the error it gives:

    Line : 17
    char : 1
    code : 0
    error : Object expected

    pls help

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    A couple of possible problems - I don't think there is a ^ operator in Javascript - Instead you can use,

    Math.pow(height * 2 * 9.81, 0.5);

    or in this case,

    Math.sqrt(height * 2 * 9.81);

    The other thing was is the function Atn defined anywhere?

    You could try using

    Math.atan2(tg);

  3. #3
    Junior Member
    Join Date
    Apr 2007
    Posts
    2
    ^ works fine
    I didn't know about the Math.sqrt, thx for that

    But I already solved my problem, it was indeed Atn that didn't work (altho i found it in the help-database from the program itself -_-)
    I had to use Math.atan(tg)

    thx for the fast reply tho

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

HTML5 Development Center