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
Solved

Simple Question about Radio Buttons in Flash

Posted on 2010-08-25
7
578 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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
you tube .com 2 206
Column Spacing 3 92
Problem to Popup 37 128
How to find the first line of javascript code-behind of a web page button. 7 88
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

860 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