Simple question about Task( )

Oct 30, 2011 at 2:07am

Simple question about Task( )

I’m trying to animate a change in a [panel]‘s presentation_rect. After some reading and experimentation, I figured the Task() object would be the most appropriate way to go. But I’m having trouble changing the arguments…

var tsk;
var args;

function init() {
        args = new Array();
	args[0] = "tick";
	tsk = new Task(dummy, this, args);
	tsk.interval = 1000;
	tsk.repeat(4);
}

function dummy(s) {
	if(s=="tick") args[0] = "tock";
	if(s=="tock") args[0] = "tick";
	post(args[0]);
}

It seems that args[0] always contains “tick” and never a “tock”. As if the initialization of Task() takes in the values of args[] upon creation, instead of checking the pointer during each interval. Or am I missing something?

Either way, i’d like to know how to get around this, or some other scripting method I could use to delay a change in an object’s attributes. Any thoughts?

#59669
Oct 31, 2011 at 2:55am
if(s=="tick") args[0] = "tock";
if(s=="tock") args[0] = "tick";

methinks you want an “else” in front of the second if.

#214763
Oct 31, 2011 at 6:05am

Thanks Brian!
346 lines of working code and I miss a simple ‘else’ statement lol

#214764

You must be logged in to reply to this topic.