Results 1 to 6 of 6
  1.    #1  
    Hey!

    Look, I've been staring at this for a while now, and I know it's getting late and I'm getting tired, and this really isn't hard, but I just don't see it...

    PLEASE tell me why this isn't looping every second. It' just PLOWS through it (counting properly) as fast as it can and exits. I need it to count slowly...

    All the variables are being passed properly and the element on the page fills in, but it just goes from black to white because this counts up with NO pausing.


    Code:
    DockAssistant.prototype.groovyFade = function (element, phrase) {
    try {
        Mojo.Log.info("GROOVYFADE", this.timerb);
        if (this.timerb < 100) {
            element.style.color = "rgba(255, 255, 255, " + (this.timerb * 0.01) + ")";
            Mojo.Log.info(this.timerw, (this.timerb * 0.01), " --", element.style.color);
            this.timerb++;
            setTimeout(this.groovyFade(element, phrase), 1000);
        }
    Have at me!


    M.
  2. #2  
    Forum rules say i'm not allowed to point out how dumb you are. That's a personal attack. So i shall say:

    "You're good enough. You're smart enough. And dog-gone-it. People like you."


    (besides i know zero about coding and have no clue what you wrote )
  3. bennish's Avatar
    Posts
    584 Posts
    Global Posts
    621 Global Posts
    #3  
    admittedly most of my knowledge lies in actionscript. but is there any kind of condition, 'while' or 'goto' kinda thing available?

    As in, are you sure it's being TOLD to loop?

    I just realised i'm the only poster in this thread whose avatar isn't holding a gun. oh dear.
    [twitter]_____[blog]______[im]__
    For now: Nexus One | iPad 2
    When avail. in Aus: Pre3 16GB | Touchpad 16GB

    This is a forum for WebOS enthusiasts. It is not a place for negative rants about Palm, HP or WebOS.
    Criticism is important but so is a positive environment. Remember, we're here because we love WebOS.
  4. #4  
    Try changing the timeout line to this:
    Code:
     setTimeout(this.groovyFade.bind(this, element, phrase), 1000);


    -- Sent from my Palm Pre using Forums
  5.    #5  
    Quote Originally Posted by rsanchez1 View Post
    Try changing the timeout line to this:
    Code:
     setTimeout(this.groovyFade.bind(this, element, phrase), 1000);


    DING DING DING! We have a winner!

    Thank you very much, man. It's now looping the way it's supposed to. Is there a reason that the "bind(this)" stuff has to be all over the place?


    M.
  6. #6  
    You have to bind the function to a proper context. If you just use a timeout without binding, then when the timeout callback is called, the context for "this" will be global, instead of DockAssistant. Since groovyFade is a method of DockAssistant and not a global function, "this.groovyFade" won't do anything and should give you an error.

    This post does a better job of explaining the concept:
    http://ajax.sys-con.com/node/676031?page=0,0

    And here is the documentation on .bind():
    http://api.prototypejs.org/language/...rototype/bind/

    -- Sent from my Palm Pre using Forums

Posting Permissions