Solved

Simple Question about Radio Buttons in Flash

Posted on 2010-08-25
7
577 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 is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how do I install adobe flash player on my ipad Air? 4 44
Apex, changing the home page, by condition 3 85
Adobe Indesign CS6 4 120
File conversion question 5 105
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

777 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