Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-06-2012, 10:04 PM   #1
superdenverdoug
King o' The Newbs
 
Join Date: Jun 2012
Posts: 2
Red face [AS3] Mysteriously Switching Radio Buttons

This is my first post here, so hello! I'm an intermediate coder looking for a bit of help, and I would appreciate it if someone could help me figure out where I can improve.

I'm coding in AS3 and have some script that I'm using to calculate a minimum credit card payment for different types of credit cards. I have a space for a user to enter in their balance (bal_text), three radio buttons (named sig, plat, and ret) to select the card type, and a submit button (calculate_btn). I've used Math.round to round out my payments to whole dollar amounts. If the minimum payment due is less than $35, the payment will display as $35. I have a dynamic text field, min_text, that displays the payment due. Here's my script:

ActionScript Code:
import flash.events.MouseEvent; stop (); calculate_btn.addEventListener(MouseEvent.CLICK, calcMinDue); function calcMinDue(e:MouseEvent):void {     var minDue : Number;     if(sig.selected = true) {         minDue = Number(bal_text.text) * .1;         minDue = Math.round(minDue);         if (minDue < 35) {             minDue = 35;         }         min_text.text = "$" + String(minDue);     }     else if(plat.selected = true) {         minDue = Number(bal_text.text) * .05;         minDue = Math.round(minDue);         if (minDue < 35) {             minDue = 35;         }         min_text.text = "$" + String(minDue);     }     else if(ret.selected = true) {         minDue = Number(bal_text.text) * .05;         minDue = Math.round(minDue);         if (minDue < 35) {             minDue = 35;         }         min_text.text = "$" + String(minDue);     } }

The math side of things is working fine (which, for me, is a big win). All the payments calculate and work the way I expect them to. The problem is that if I select any radio button other than "sig," Flash changes my selection to the "sig" radio button and performs the proper calculation when I press my calculate_btn.

Any thoughts on what's going on here?

Last edited by superdenverdoug; 06-06-2012 at 10:08 PM. Reason: wrong starting place for AS tag
superdenverdoug is offline   Reply With Quote
Old 06-07-2012, 12:42 AM   #2
Sonny
Senior Member
 
Join Date: Aug 2010
Location: Sydney,Australia
Posts: 132
Default

There is nothing so mysterious about it
change
ActionScript Code:
if(sig.selected = true)
to
ActionScript Code:
if(sig.selected == true)
or
ActionScript Code:
if(sig.selected)
and do the same for all the if statements

Last edited by Sonny; 06-07-2012 at 12:46 AM.
Sonny is offline   Reply With Quote
Old 06-07-2012, 02:28 PM   #3
superdenverdoug
King o' The Newbs
 
Join Date: Jun 2012
Posts: 2
Default

Ah, overlooking the obvious. My specialty.

Thanks!
superdenverdoug is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:37 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.