Solved

Simple Question about Radio Buttons in Flash

Posted on 2010-08-25
7
574 Views
Last Modified: 2013-11-12
Hello,I seem to be having trouble using radio buttons with Flash and as 2.
Here is the problem. I am currently coding an exam entirely in Adobe Flash. It is a simple multiple choice exam, where there are four choices underneath each question. When the user selects the right answer, a point is added to the dynamic textbox with the variable name " total". At this point it should be added that the answers will only be selected when the user clicks on a radio button, they will be added to the textox when he/she clicks the submit button (where the actionscript code is). Please check the code attached to see what I have so far. I have successfully created this same kind of exam online with PHP and MySQL but seem to have trouble migrating to Flash. Whenever I use the code below, I get the several syntax errors.

Can anyone tell me where I wrong?
on (release) {

    if (q1.getValue()=="4") {

	_root.total = _root.total + 100;

    }

else {

	_root.total = _root.total + 0;

    }



    if (q2.getValue()=="18") {

	_root.total = _root.total + 100;;

    } else {

	_root.total = _root.total + 0;

    }

}

        _root.total = _root.total + 100 ;

Open in new window

0
Comment
Question by:ximenao
  • 4
  • 2
7 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 33528602
i'm not sure what your question is, but in terms of the syntax issues it will be much easier if you tell us specifically what the errors are.

but the obvious thing that jumps out.

1. i'm assuming this code in in the button actions  and NOT timeline / frame - otherwise it will throw an error.
2. the last line of code _root.total = _root.total + 100; is hanging around out of place, it should be in the on(release) code block as well.
3. does getValue() return strings?

4. not an error just a short cut

_root.total += 10; is the same as _root.total = _root.total + 10; //just less typing
0
 

Author Comment

by:ximenao
ID: 33529871
Thanks for responding blue-genie, and for the tip.
Looking at the code I posted I realize that I made an error in posting; the final line _root.total = _root.total + 100; was posted by accident. The actual code is everything above it.
And whenever I use that code, I get the following errors:

frarSyntax error.
0
 

Author Comment

by:ximenao
ID: 33529894
Sorry, here the errors I get:
Syntax error—if (q1.getValue()=="b") {
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:ximenao
ID: 33529919
Having some difficulty posting these errors. Here are the rest, attached as code.

And the getValue() is meant to return a string.
Statement must appear within on handler—_root.total = _root.total + 100;
Syntax error—} else {

Open in new window

0
 
LVL 4

Accepted Solution

by:
andreMariano earned 500 total points
ID: 33530158
first of all... why are you adding 100 point in the end... well... I don't know what's coming in the "getValue()" anyway... the best way for your code is:
on (release) {
    if (q1.getValue()=="4") {
	_root.total = _root.total + 100;
    }
    if (q2.getValue()=="18") {
	_root.total = _root.total + 100;
    } 
}

Open in new window

0
 
LVL 39

Expert Comment

by:blue-genie
ID: 33530253
I'm just going to follow on from my thread and train of thought here so if what andreMariano says conflicts with what I'm saying - pick one route.

statement must appear within on handler—_root.total = _root.total + 100 - that is the error i was referring to where that last line must appear within the statement, which you said it shouldnt' so if you delete that then that error should fall away.

you are attaching the code to the movieclip and NOT to the timeline right?


would be easier if you could upload your file if you're still getting errors after this.
0
 

Author Comment

by:ximenao
ID: 33530342
Thank both of you for all your help.... the code works perfectly now.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now