Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Location
    Farmington Hills, MI
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy setTimeout and objects

    Ugh. Two days of scripting and searching, and I can't find this answer anywhere. Please help!

    Whenever I try to use setTimeout with anything object-related, I usually end up trying set my computer ablaze.

    For instance, I have two <div> objects...I most likely will have to build more down the road. Internal website, so I only have to code for IE5 (and was told to only code for this). Each layer div object has a button that should be able to slide down a specified distance, and when the button is clicked again, up it goes. I prefer to use the slide animation if at all possible, but I've been having multiple problems. Here is the latest:


    //I would fire this off by -> onclick = "passFunc('dragWin');return false;"

    function getobje(divName){
    this.divObj = document.all[divName]
    this.css = document.all[divName].style
    this.divTop = document.all[divName].style.top
    this.divLeft = document.all[divName].style.left
    this.state = true
    this.slideWin = slideWinUp;
    }

    function passFunc(objStr){
    theObj = new getobje(objStr):0
    theObj.slideWin()
    }

    function slideWinUp(){
    if(this.state){
    if(parseInt(theObj.divTop)!=0){
    theObj.divTop = parseInt(theObj.divTop)+14
    setTimeout(theObj +'.slideWin()',20)
    }
    else{
    clearTimeout();
    this.state = false
    return 0;
    }
    }
    else {
    if(parseInt(theObj.divTop)!= -280){
    theObj.divTop = parseInt(theObj.divTop)-14
    setTimeout('slideWinUp()',20)
    }
    else{
    clearTimeout();
    this.state = true
    return 0;
    }
    }

    }


    After I put some alert statements in there, I found that the properties were in fact changing, but no animation. I've tried to simply pass an object as an argument to the slideWinUp() function, but it only knows about the object once.

    PLEASE, please help.


    --Jae.

  • #2
    New to the CF scene
    Join Date
    Jun 2002
    Location
    Farmington Hills, MI
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    Thanks, I'll give that a go.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Atlanta, GA.
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You might want to take a look at this thread.
    custom objects & window.setTimeout
    The answer does not come from thinking outside the box, it comes from realizing the truth :-
    "There Is No Box". [JavaScript Gadgets'n'Gizmos][JavaScript-FX]


  •  

    Posting Permissions

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