FORUMS: list search recent posts

Actionsript that is live, not just "on enterframe" help :)

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
og_Borat
Actionsript that is live, not just "on enterframe" help :)
on May 9, 2007 at 11:00:03 am

Hi
I've got a little problem

I have a page that does some money calculations, and at the bottom it shows you your total.
its all working fine, until someone leaves a field blank, eg with no "0"
The page loads up with 0's in all boxes but if someone deletes one then I get the NaN result.

So I added a script that said "if a1 (the box with 0 in it) = "" then a1 =0 so that's saying if there is nothing in box "a1" make it 0. This works but only if you go to the next page and then back again.

Is there a way to make this script always live? so as soon as someone deletes the 0 and they move to the next box, it reads the script and puts the 0 back?



Return to posts index

DaveTrep
Re: Actionsript that is live, not just "on enterframe" help :)
on May 9, 2007 at 3:12:41 pm

Hi og_Borat

The following code should help you check if a text has been entered into a number field and reset the value to 0.


if (testNumber.toString() == "NaN") {
trace("not a number");
testNumber = 0;
}

Hope this helps

Dave.


Return to posts index

Mike_S
Re: Actionsript that is live, not just "on enterframe" help :)
on May 9, 2007 at 4:28:03 pm

A similar approach without the string function might look like this:
an input text field (here called myText) with its var set to myUpdate.

When the user leaves the field (onKillFocus), the isNan function checks to see whether the variable store (myUpdate) is a number - if not, it sets the variable (and hence the field) to zero ...

var myUpdate = "your initial value";
_root.myText.text = myUpdate;
_root.myText.onKillFocus = function() {
if (isNan(myUpdate)) {
myUpdate=0;
}
};


Return to posts index


og_borat
Re: Actionsript that is live, not just "on enterframe" help :)
on May 10, 2007 at 12:54:19 am

Thanks guys!!!!!

They worked a treat, your life savers.

I really appreciate the fast and easy to understand responses.

Thanks again.
Michael.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]