<< Chapter < Page Chapter >> Page >
Listing

Source code for quiza.as.

package CustomClasses{ import flash.events.*;import mx.containers.VBox; import mx.controls.Button;import mx.controls.RadioButton; import mx.controls.TextArea;import mx.events.FlexEvent;public class QuizA extends VBox{ private var theQuestion:TextArea;private var choice00:RadioButton; private var choice01:RadioButton;private var choice02:RadioButton; private var checkButton:Button;private var result:TextArea;private var theAnswer:String;//numeric string private var correctAnswer:String;//actual stringprivate var vboxWidth:int = 375; //==================================================//public function set question(textIn:String):void{theQuestion.text = textIn; }//end implicit setterpublic function set answer(answerIn:String):void{theAnswer = answerIn; }//end implicit setterpublic function set choice0(choice:String):void{choice00.label=choice; }//end implicit setterpublic function set choice1(choice:String):void{choice01.label=choice; }//end implicit setterpublic function set choice2(choice:String):void{choice02.label=choice; }//end implicit setter//==================================================//public function QuizA(){//constructor width=vboxWidth;setStyle("borderStyle","solid"); setStyle("backgroundColor",0xffff00);theQuestion = new TextArea();theQuestion.editable = false; theQuestion.width=vboxWidth - 2;addChild(theQuestion); choice00 = new RadioButton();choice00.groupName="radioButtonGroup"; addChild(choice00);choice01 = new RadioButton();choice01.groupName="radioButtonGroup"; addChild(choice01);choice02 = new RadioButton();choice02.groupName="radioButtonGroup"; addChild(choice02);checkButton = new Button();checkButton.label = "Click to Check Answer"; checkButton.addEventListener(MouseEvent.CLICK,checkButtonHandler); addChild(checkButton);result = new TextArea();result.editable = false; result.width=vboxWidth - 2;result.visible=false;addChild(result);//Register an event listener that will be // executed when this object has been fully// constructed. It will set the height of // the VBox based on the sum of the heights// of the components. this.addEventListener(mx.events.FlexEvent.CREATION_COMPLETE, vboxCompleteHandler);}//end constructor //==================================================//private function checkButtonHandler(event:MouseEvent):void{ result.visible=true;if(theAnswer == "0"){correctAnswer = choice00.label; }else if(theAnswer == "1"){correctAnswer = choice01.label; }else{correctAnswer = choice02.label; }//end elseif((theAnswer=="0"&&choice00.selected) || (theAnswer=="1"&&choice01.selected) || (theAnswer=="2"&&choice02.selected)){result.setStyle("color",0x00ff00); result.text = "Correct\nCorrect Answer is: "+ correctAnswer; }else{result.setStyle("color",0xff0000); result.text = "Wrong\nCorrect Answer is: "+ correctAnswer; }//end else}//end checkButtonHandler //==================================================//private function vboxCompleteHandler(event:mx.events.FlexEvent):void{ //Set the height equal to the sum of the// heights of the components plus six // pixels per component to account for the// space between components. this.height =theQuestion.height + choice00.height+ choice01.height + choice02.height+ checkButton.height + result.height+ 36;//six spaces per compnent }//end vboxCompleteHandler//==================================================// }//end class}//end package

Questions & Answers

Explain the following terms . (1) Abiotic factors in an ecosystem
Nomai Reply
Abiotic factors are non living components of ecosystem.These include physical and chemical elements like temperature,light,water,soil,air quality and oxygen etc
Qasim
what is biology
daniel Reply
what is diffusion
Emmanuel Reply
passive process of transport of low-molecular weight material according to its concentration gradient
AI-Robot
what is production?
Catherine
Pathogens and diseases
how did the oxygen help a human being
Achol Reply
how did the nutrition help the plants
Achol Reply
Biology is a branch of Natural science which deals/About living Organism.
Ahmedin Reply
what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
cell is the smallest unit of the humanity biologically
Abraham
what is biology
Victoria Reply
what is biology
Abraham
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is respiration
Deborah
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with actionscript. OpenStax CNX. Jun 04, 2010 Download for free at http://cnx.org/content/col11202/1.19
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with actionscript' conversation and receive update notifications?

Ask