[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Simple Question about Radio Buttons in Flash

Posted on 2010-08-25
7
Medium Priority
?
583 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The goal of the tutorial is to teach the user how to how to record live broadcast.

656 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