Hi there, I was trying to make up a triggering system for the objects in my stage. For example, the ending of a sound track must be able to trigger the visibility of a text field already added to the page sprite in the stage. To do this I'm using SPEvents: the page sprite registers to the channel that will play the sound and starts listening for SP_EVENT_TYPE_SOUND_COMPLETED. When receiving the event a method for setting the visibility of the field is invoked. Now the main problem is that I'm adding the event listener to the channel (exactly after creating the text field), so when the page sprite receives the end of sound event, it doesn't know what object to display on the screen (my method for displaying object must be as much generic as possible).
My idea was to modify the sparrow framework to give the ability to events to carry out informations, not only the object that dispatched the event. Do you think there is a simpler way?
This is the code I wrote:
else if ([anElement.type isEqualToString:@"text"]) { // TEXT SPTextField *text = [SPTextField textFieldWithText:anElement.text]; text.width = anElement.width; text.height = anElement.height; text.x = anElement.x; text.y = anElement.y; text.fontName = anElement.fontName; text.fontSize = anElement.fontSize; text.color = anElement.fontColor; [self.channel addEventListener:@selector(addObjectToPageSprite:) atObject:self forType:SP_EVENT_TYPE_SOUND_COMPLETED retainObject:YES]; } - (void)addObjectToPageSprite:(SPEvent *)event { }