PDA

View Full Version : onTargetReached()


Da_Pipe
9th January 2003, 01:04
i'm playing around with fading groups out. but i have run into a little problem. here is the code:

fadeIt(Group fade, int to) {
int objs = fade.getNumObjects();
for(int i = 0; i<objs; i++){
Guiobject obj = fade.enumObject(i);
if (to == 255) obj.show();
obj.setTargetA(to);
obj.settargetSpeed(1);
obj.gotoTarget();
obj.onTargetReached() {
if (to == 0) {
obj.hide();
}
}
}
}

the problem i'm having is mc.exe gives me a syntax error on "obj.onTargetReached() {" . and as far as i can tell it's ok. if i remove the {} and add it like this: "obj.onTargetReached();" it compiles fine. so can someone tell me what is causeing the syntax error? is it another damn maki bug?

btw- i couldn't find anything on this on bugzilla.

mc^^^^
9th January 2003, 01:16
ontarget reached is not to be put inside the initial thingy. its its own function thing. like onleftbutttondown and stuff

do this:


fadeIt(Group fade, int to) {
int objs = fade.getNumObjects();
for(int i = 0; i<objs; i++){
Guiobject obj = fade.enumObject(i);
if (to == 255) obj.show();
obj.setTargetA(to);
obj.settargetSpeed(1);
obj.gotoTarget();
}
}

obj.onTargetReached() {
if (to == 0) {
obj.hide();
}
}

Da_Pipe
9th January 2003, 01:22
i was afraid of that. that's a loop i'm trying to call it in. so if you move it outside the loop it's pointless to even have it. thanks anyway. i'll have to figure something out.

Strike&Co.
9th January 2003, 03:19
What happens if you make obj a global object, and use mc^^^'s code?

Will that link up the onTargetReached() code to all the objects, or just whichever one happens to be obj at the time?

If you have any idea what the most objs any group will have is, you could just cut & paste that many objN.onTargetReached() functions and play with the current loop code.. It'll get long if theres a bunch of objects in the group though.
If only MAKI supported arrays... oh well, thats part of the challenge, I suppose ^_^

Hollow
9th January 2003, 03:47
Just for future edification all function that are prefaced with 'on' are events, functions that winamp calls, that you place code in.

All of them.

iPlayTheSpoons
9th January 2003, 04:14
you know....hide() will work on an entie group, so you dont need to have each obj defined seperately. and, you only need for winamp to know ONE of the objects (or, the last one) has reached its target before trigering. so, if you put obj.onTargetReached() { goup.hide(); }, then when the last obj the for loop defined as obj reached its targetA, it wouls just hide the whole group, which is what you want anayway

i did something recently where a drawer had stuff slide down from within its group once it reached where it was going. this mean i had to have the 4 sets (it was three buttons and a layer) slide down. when goin back, tey would slide up, and when one of them got there (i didnt need to know all of them got there, cuz they were goin the same place at the same time), the whole mess slid back in...maybe this will help:


Togglein.onLeftClick() {
if (B == 1) {
B = 0;
Togglein.hide();
Toggleout.show();
presets.setTargetY(110);
presets.setTargetSpeed(0.5);
presets.gotoTarget();
power.setTargetY(110);
power.setTargetSpeed(0.5);
power.gotoTarget();
auto.setTargetY(110);
auto.setTargetSpeed(0.5);
auto.gotoTarget();
buttonback.setTargetY(89);
buttonback.setTargetSpeed(0.5);
buttonback.gotoTarget();
shadow.setTargetY(83);
shadow.setTargetSpeed(0.5);
shadow.gotoTarget();
}
buttonback.onTargetReached() {
if (B == 0) {
Equalizer.setTargetX(118);
Equalizer.setTargetSpeed(0.5);
Equalizer.gotoTarget();
}


now, i defined shit the long way, but its the same idea

Da_Pipe
9th January 2003, 12:15
iplaythespoons, yeah i figured that out last night while i was trying to sleep. i'll try it and see if i can get it to work. thanks for the help.

hollow, thanks for the information. now that you've said that i understand why it wouldn't work the way i had it.