Learn a little about flash (46) single answer questions every day

Source: Internet
Author: User

Today, I am bored with reading the usage of this check box. It is indeed a good choice to use it to create multiple choice questions. Drag four components on the component panel,

Modify its label to make it an appropriate answer. There are also some data values and the selected status.

After setting the attributes of the component, let's start making the component. The idea is: since it is a single-choice question, each single-choice question has a unique answer. There are only two States: Correct answer and wrong answer. If a question has a score or no score, we can set a variable value for each question. This variable value is used to calculate the score of this question. Because it is done in several frames, a global variable is set for each question. See the following code

The first frame of code:

Stop ();

_global.sum=0;var obj=new Object();obj.click=function(evt){ if (evt.target ==mc1){   sum=evt.target.data;trace(sum);}else if(evt.target ==mc2){sum=evt.target.data;trace(sum);}else if(evt.target ==mc3){sum=evt.target.data;trace(sum);}else if(evt.target ==mc4){sum=evt.target.data;trace(sum);}}mc1.addEventListener("click",obj);mc2.addEventListener("click",obj);mc3.addEventListener("click",obj);mc4.addEventListener("click",obj);

 

Set the name of each component to mc1, MC2, MC3, and mc4.

 

Frame 2:

Stop ();

_global.sum2=0;var obj=new Object();obj.click=function(evt){ if (evt.target ==mc5){   sum2=evt.target.data;trace(sum2);}else if(evt.target ==mc6){sum2=evt.target.data;trace(sum2);}else if(evt.target ==mc7){sum2=evt.target.data;trace(sum2);}else if(evt.target ==mc8){sum2=evt.target.data;trace(sum2);}}mc5.addEventListener("click",obj);mc6.addEventListener("click",obj);mc7.addEventListener("click",obj);mc8.addEventListener("click",obj);

 

Finally, calculate the total score of each choice question:

Frame 3:

stop();btn2.onRelease=function(){msg=sum+sum2;trace(msg);}

 

Well, This completes the scoring of two single-choice questions, which is good for multimedia.

Note recorded! Tired ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.