Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- btnCount.addEventListener(MouseEvent.CLICK, countVowels);
- txtinSentence.addEventListener(MouseEvent.CLICK, clearLabels);
- function countVowels(e:MouseEvent):void {
- var phrase: String;
- var current_char: String;
- var is_vowel: Boolean;
- var num_vowels: int;
- var vowel_types: String;
- vowel_letters = "aeoui";
- phrase = txtinSentence.text;
- // iterate through each char, looking for vowels
- for (i = 0; i < str.length; i++) { // 'i' is a counter
- current_char = phrase.charAt(i); // use 'i' to index the phrase
- if(vowel_letters.indexOf(current_char) >= 0) { // actionscript is horrible
- num_vowels += 1; // yay there's a vowel
- }
- }
- // output the text
- lblOutput.text += "There are " + num_vowels + " in the sentence";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement