Skip to main content

CS Flex 3 Test Revision

Task One:

1. You have two buttons. One labeled "Timestable" and the other "Divison table". The Timestable button calls the timesTable function, and the Division table button calls the divisionTable function.
2. Assume that the logIT function has already been given, write the codes for the timesTable and divisionTable functions so that as the button is clicked, the respective tables will be printed out in the debug logger.

Answer:

private function timesTable ():void{
for (var i:int=0; i<13; i++){
for (var j:int=0; j<13; j++){
logIT (String(i) + ' times ' + String(j) + ' = ' + String (i*j));
}
}
}

private function divisionTable ():void{
for (var i:int=0; i<13; i++){
for (var j:int=0; j<13; j++){
logIT (String(i*j) + ' divided by ' + String(i) + ' = ' + String (j));
}
}
}

 
 
Task Two:
 
1. You are given a text input box and a button. On click of the button, whatever information from the text input box will be in reversed order and displayed in Alert.show.
2. Write the codes for that function.
 
Answer:
 
Create a variable to extract information from the text input box, and another variable to be displayed on the Alert.show.
 
private function reverseText ():void{
var reverseText:String = txiInput.text;
var inAlert:String = ' ';
for (var i:int= reverseText.length-1; i<-1; i--){
inAlert = inAlert + reverseText.charAt(i);
}
 Alert.show(inAlert);
}
 
 
 
Task Three:
 
1. You are given a text input box and a button.
2. Create a function whereby on click, the total of vowels in whatever information from the text input box is displayed in Alert.show. Change upper case characters to lower case when extracting information from the text input box.
 
 
Answer:
 
Similar to the previous problem, a variable must be created to extract information from the text input box, as well as to display or count the number of vowels.
 
You can use: a switch statement, five if statements or one if statement.
 
using switch:
 
private function vowelCount():void{
var sampleText:String txiInput.text.toLowercase();
var vowelTotal:int = 0;
for (var i:int=0; i
switch (sampleText.charAt(i)){
case 'a': vowelTotal++;
             break;
case 'e': vowelTotal++;
             break;
case 'i': voweTotal++;
             break;
case 'o': vowelTotal++;
             break;
case 'u': vowelTotal++;
             break;
default:  break;
}
}
Alert.show ('Total vowel is ' + String(vowelTotal));
}
 
 
erh, I'll figure out the if statement sometime.

Comments

Nana said…
for task three, actually the for loop code is:

for(var i:int=0; i<sampleText.length; i++)

I don't know why blogger doesn't like it, so I've not been able to display it.

Popular posts from this blog

My Unintended

I'm going back today =( My class is seemingly doing a drama on inter-species romance. An alien princess with a homo sapien teenager. It's gonna be fun. The props are gonna be out-of-this-world and maybe, kind of complex to make, but all the same, marvelous if we can pull it off. For the setting, we might be doing a space backdrop. Costumes, perhaps a blend of futuristic, contemporary and medievel and a little touch of Goth as it will be in a modern-day Halloween setting. We haven't discussed the storyline yet, but it's going to be a fusion of comedy, action and the lot.. Inspirations come from an array of popular sci-fi characters from Star Wars, Star Trek and a Malay short story Anyss Sophillea. I just can't wait.

Outta..Control!

Sometimes in life, we have to laugh ourselves silly..laughing at ourselves! Life must go on and there will always be more room for improvement. So, for my last post before I go back to school, I'm gonna put my debating pictures, then and now.. just for fun see how much I've evolved from the 4-minute emo speech to the 8-minute still emo speech, haha. however, I haven't any pictures on my public speaking though, so I don't know how I fared. One judge commented me last year that I was as stiff as a robot! so, here we go! THEN UIA 2007- against RMC, yep, this is the one I'm talking about! The most embarrassing debate, aww, my first time.. look at Mirul, covering his face in shame, Kak Ainul, praying kot? and at the back at that time, Teacher Rozy was having a good laugh with Amirul Irfan, RMC's researve at that time. okay..this went out of hand! what the hell was I doing?? These pictures are really old ones that reside in my thumbdrive that I have yet to upload.haha...

My Fair Lady

This is an old issue, I know. What has brought my attention to the topic of women rights was when I watched one of the episodes of Commander In Chief on Hallmark. In that series, the president of the United States was supposedly a woman. Interesting, and she plans to take the stand for women rights to the next level despite the controversies arousing her brave statement. The debate was whether or not it was relevant to debate on an old issue, in respect of the state of today's society. Women of today have a better status than they did way back in the days of history old. Women emancipation has been heatedly debated especially in the West throughout the time, and perhaps, the most memorable one was of the Suffragettes, fighting for the right of women to vote. Some places in Africa, in history, do not even recognize rape of women, as a crime, however, all of that has changed, thankfully. The question now is, are women actually 'emancipated' as we are all made to belief? well,...