matbury
11-04-2007, 03:09 AM
Ok, as you know, I'm new to the dark art of OOP, but doing my best to get to grips with it, so this question is for wizards who are well versed with this magical way.
To save me a lot of time and keyboard-head-banging and to get me started in the right direction, I'm making a dictation exercise - not the banana republic kind, the listen and type what you hear kind - and I'd like some advice.
What I have to do is the following:
Load in an XML file containing the 'Timed Text' captions data. The nodes look like this:
<CuePoint>
<Time>5146</Time>
<Type>event</Type>
<Name>If you are codependent, ask someone to press two for you.</Name>
</CuePoint>
(It's actually meant for <FLVCoreCuePoints> XML - so it's a pretty useful standard to go by.)
For each node, split the <Name> tag text into individual words and store them in an array.
i.e. var firstNode1Array:Array = new Array("If", "you", "are", "codependent,", "ask", "someone", "to", "press", "two", "for", "you.");
Make a copy of the array and remove any punctuation (i.e. full-stops, commas, convert upper-case to lower, etc.)
i.e. var secondNode1Array:Array = new Array("if", "you", "are", "codependent", "ask", "someone", "to", "press", "two", "for", "you");
Create input TextFields that correspond to the words in the firstNode1Array array.
i.e. |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___|.
Place all the text fields on the stage and put a 'listen' button, loaded from the FLA library, at the front of each sentence like this:
i.e. 'listen' |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___| 'listen' |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___| 'listen' |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___| 'listen' |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___|.
Load in an MP3 file.
Listen for when a user clicks on a 'listen' button and play the MP3 file at the corresponding <CuePoint> e.g. 5146 milliseconds.
Listen for KEY_UP events and check the input text of the focussed input TextField against the corresponding string in the secondNode1Array.
Individually, I can write all this code. I could write it all into one, big, unruly, messy class. I think OOP can offer a much better way.
So my UML-type question is this:
Which responsibilities should I divide into which classes and how should the classes relate to each other?
i.e. with regards to namespacing variables and functions, which classes extend which, when to use listeners or share functions, etc.
It'd really help me so much to know how you guys would approach this kind of problem. You've been my 'Open University' for a while now, and I really respect your advice.
Thanks in advance!
To save me a lot of time and keyboard-head-banging and to get me started in the right direction, I'm making a dictation exercise - not the banana republic kind, the listen and type what you hear kind - and I'd like some advice.
What I have to do is the following:
Load in an XML file containing the 'Timed Text' captions data. The nodes look like this:
<CuePoint>
<Time>5146</Time>
<Type>event</Type>
<Name>If you are codependent, ask someone to press two for you.</Name>
</CuePoint>
(It's actually meant for <FLVCoreCuePoints> XML - so it's a pretty useful standard to go by.)
For each node, split the <Name> tag text into individual words and store them in an array.
i.e. var firstNode1Array:Array = new Array("If", "you", "are", "codependent,", "ask", "someone", "to", "press", "two", "for", "you.");
Make a copy of the array and remove any punctuation (i.e. full-stops, commas, convert upper-case to lower, etc.)
i.e. var secondNode1Array:Array = new Array("if", "you", "are", "codependent", "ask", "someone", "to", "press", "two", "for", "you");
Create input TextFields that correspond to the words in the firstNode1Array array.
i.e. |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___|.
Place all the text fields on the stage and put a 'listen' button, loaded from the FLA library, at the front of each sentence like this:
i.e. 'listen' |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___| 'listen' |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___| 'listen' |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___| 'listen' |__| |___| |___| |___________| |___| |_______| |__| |_____| |___| |___ |___|.
Load in an MP3 file.
Listen for when a user clicks on a 'listen' button and play the MP3 file at the corresponding <CuePoint> e.g. 5146 milliseconds.
Listen for KEY_UP events and check the input text of the focussed input TextField against the corresponding string in the secondNode1Array.
Individually, I can write all this code. I could write it all into one, big, unruly, messy class. I think OOP can offer a much better way.
So my UML-type question is this:
Which responsibilities should I divide into which classes and how should the classes relate to each other?
i.e. with regards to namespacing variables and functions, which classes extend which, when to use listeners or share functions, etc.
It'd really help me so much to know how you guys would approach this kind of problem. You've been my 'Open University' for a while now, and I really respect your advice.
Thanks in advance!