actionscript 3 - OOP: trouble notifying other objects in hierarchy -
I consider the hierarchy of objects I always struggle quiz with sending messages between objects:
< ul>- Prsnsuchi
- question
- North list
- Answer
- North list
- question
it:
a quiz question list - multiple questions in a question list - no question a Answer list is there
There are many answers in a reply list
When someone Answer is clicked (We are talking Flash AS3 here):
Answer indicates the answer.
Answers the question answers. The question indicates question listing. The quiz indicates the quiz.
In other words, the message bubbles up. This is possible because I pass each 'parent' object through the creator of its 'collector' but I think I read somewhere that the objects should not be aware of their parents.
Thank you
Yes, you do not want children to their parents Let object link I think you have to expand the position, he has a performance hierarchy that case, you can do it better by using the event system. You can create custom events that are sent when things happen and parents will add events to the care of them to take care of them.
A possible event scenario for your structure would be the following example:
- The answer (a button) is clicked, and the hearing list answers the notice.
- A "answered" event is posted in the answer list, which is received by the question.
- "Answered" event has been sent to inform the question list for marking this question as answer to the question
- When the question list answers all the questions If the given events have been received, it tells an "end" event it is complete that the quiz
Comments
Post a Comment