Thursday, 24 November 2011

Assignment 1 - Exercise 1

 Exercise 1

Multiple choice question using dialog box.

In this exercise, user need to choose the correct answer for the clothes given and press "Submit" button.

Below is the flash.




First, we create multiple choice question on the stage.

Then, we add ComboBox component by:

  1. Window > Components > User Interface > ComboBox.
  2. Select the component on the stage, and name the instance name as box in the properties panel.
  3. To add answer options,  Window > Components Inspector > Data. Click + to write the answers.
  4. Repeat the same step above for labels.

Add stop(); actionscript and "Submit" button in keyframe 1.

Insert a dynamic text box in keyframe 2 as a feedback for write or wrong answer. Var : jg

Actionscript behind "Submit" button (in keyframe 1):
                on (press) {
                if (box.getValue()=="shirt"){
                                                jg="Sorry,wrong answer! Please select again!";
                }
                if (box.getValue()=="night dress"){
                                                jg="Sorry,wrong answer! Please select again!";
                }
                if (box.getValue()=="pyjamas"){
                                                jg="Congratulations! It is a pyjamas.";
                }
                                                gotoAndStop(2);
                }

Insert "Try Again" button with actionscript (in keyframe 2):
                on (release) {
                gotoAndStop(1);
                jg="";
                }

* For more details, refer to Nur Aminah's blog.

No comments:

Post a Comment