What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Timeout Objects

Timeout Objects
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Timeout Objects
Well, actually there's no need to add so many arguments. You could simply make another function which passes the right parameters and use that as callback, like so:
js code:
function somefunction(arg1, arg2, arg3) {
    // Do something useful
}

// Method 1: hard-coded parameters inside new function
var callback = function(timer) {
    somefunction("aa", 123, 3.14159);
};
new Timer(1000, callback);

// Method 2: use array to get parameters
var callback = function(timer, args) {
    // Pass each element in the args array as parameter
    somefunction.apply(null, args);
};
var param = ["aa", 123, 3.14159];
new Timer(1000, callback, param);
As you can see, by using some clever coding you can even omit sending the parameter! Of course, this will make your callback function less portable, but it'll save you some precious code in your class itself.

And most important of all: you can avoid using eval() (since everybody knows that eval is evil!)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
09-20-2009 05:47 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Timeout Objects - by trevorpe on 09-19-2009 at 11:35 PM
RE: Timeout Objects - by roflmao456 on 09-20-2009 at 01:08 AM
RE: Timeout Objects - by Matti on 09-20-2009 at 06:54 AM
RE: Timeout Objects - by trevorpe on 09-20-2009 at 11:23 AM
RE: Timeout Objects - by Matti on 09-20-2009 at 05:47 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On