Skip to main content
Known Participant
April 24, 2007
Answered

setInterval in 2.0.4

  • April 24, 2007
  • 5 replies
  • 561 views
Hi

I've just read the release notes for 2.0.4 and it says this:


In the Flash Media Server 2 Server-Side ActionScript Language Reference manual, on page 115-116, one of the methods used to invoke setInterval() is no longer valid. The first method, setInterval(function, interval[, p1, …, pN]) is correct and should be used. The second method, setInterval (object, methodName, interval[, p1, …, pN]) is not valid.

I've been testing with 2.0.4 using the second method and everything works fine.

Can someone let me know if the second method has been deprecated?

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Correct answer Newsgroup_User
    Hello :)

    You can use the setInterval method with 2 cases :

    var myInterval = setInterval( myObj, "echo" , 5000, new Date() ) ;

    First argument is an object and the second the name of the method to
    call in this object (the method in this example can not exist ! it's a
    problem)

    or

    var myInterval = setInterval( echo , 5000 ) ; // you must use in the
    first argument the 'Function' object and not a 'String' Object.

    EKA+ :)

    bdbdfddfgfgdfg a écrit :
    > looking further into this problem i tried the following code
    >
    > function obj()
    > {
    > }
    >
    > obj.prototype.echo = function()
    > {
    > trace( "object trace called with " + new Date() );
    > }
    >
    > function echo()
    > {
    > trace( "trace called with " + new Date() );
    > }
    >
    >
    > trace( new Date() );
    >
    > var myObj = new obj();
    >
    > var myInterval = setInterval( myObj, "echo" , 5000, new Date() ); // works
    > //var myInterval = setInterval( "echo" , 5000 ); // doesnt work
    >
    > strangely enough the code they say should work doesnt and the code they say
    > doesnt does :/
    >

    5 replies

    Newsgroup_UserCorrect answer
    Inspiring
    April 24, 2007
    Hello :)

    You can use the setInterval method with 2 cases :

    var myInterval = setInterval( myObj, "echo" , 5000, new Date() ) ;

    First argument is an object and the second the name of the method to
    call in this object (the method in this example can not exist ! it's a
    problem)

    or

    var myInterval = setInterval( echo , 5000 ) ; // you must use in the
    first argument the 'Function' object and not a 'String' Object.

    EKA+ :)

    bdbdfddfgfgdfg a écrit :
    > looking further into this problem i tried the following code
    >
    > function obj()
    > {
    > }
    >
    > obj.prototype.echo = function()
    > {
    > trace( "object trace called with " + new Date() );
    > }
    >
    > function echo()
    > {
    > trace( "trace called with " + new Date() );
    > }
    >
    >
    > trace( new Date() );
    >
    > var myObj = new obj();
    >
    > var myInterval = setInterval( myObj, "echo" , 5000, new Date() ); // works
    > //var myInterval = setInterval( "echo" , 5000 ); // doesnt work
    >
    > strangely enough the code they say should work doesnt and the code they say
    > doesnt does :/
    >
    Known Participant
    April 24, 2007
    Thanks for replying eka :)

    It looks like both ways still work in 2.0.4.

    What i find confusing is that in the release notes for 2.0.4 it clearly says the following:
    In the Flash Media Server 2 Server-Side ActionScript Language Reference manual, on page 115-116, one of the methods used to invoke setInterval() is no longer valid. The first method, setInterval(function, interval[, p1, …, pN]) is correct and should be used. The second method, setInterval (object, methodName, interval[, p1, …, pN]) is not valid.

    My real question is:

    Does this mean that the object way has been deprecated, and if so are they going to phase it out in the next release?

    I really hope not, the first method is really limited, especially when you want to produce complex applications.
    Known Participant
    April 24, 2007
    looking further into this problem i tried the following code

    function obj()
    {
    }

    obj.prototype.echo = function()
    {
    trace( "object trace called with " + new Date() );
    }

    function echo()
    {
    trace( "trace called with " + new Date() );
    }


    trace( new Date() );

    var myObj = new obj();

    var myInterval = setInterval( myObj, "echo" , 5000, new Date() ); // works
    //var myInterval = setInterval( "echo" , 5000 ); // doesnt work
    var myInterval = setInterval( echo , 5000, new Date() ); // works