A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Nan help

  1. #1
    Senior Member
    Join Date
    Jun 2003
    Posts
    231

    Nan help

    I'm banging my head aginst the wall on this simple one. Please help. I'm getting a NAN in my text fields with this code from a button.. What the heck am I doing wrong?

    on (release) {
    _root.orderform.quantity1 = Number(_root.orderform.quantity1)+1;
    _root.orderform.total1 = _root.orderform.quantity1*45;
    }

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    try tracing out your variables..before you add them.. are you even finding/getting your variables?

    I also suggest you dont use any OBJECT code any more.. (ie: putting CODE on the button itself).. all code SHOULD go in 1 frame (frame1) in the timeline..

    and you should also never use _root.. use relative pathing to your data & objects(ie: this._parent........etc)

    a quick test..shows this works just fine:

    this is on _root:
    var total1 = 2;
    var quantity1 = 1;


    this is button nested inside 1 clip


    button.onPress = function() {
    _root.quantity1 += 1;
    trace("QTY: "+_root.quantity1);

    _root.total1 = (_root.quantity1 * 45);
    trace("TOTAL 2: "+_root.total1);
    };



    so really, ideally, your code should all be in frame 1..and look similar to this:

    var total1 = 2;
    var quantity1 = 1;


    containerClip.button.onPress = function() {
    quantity1 += 1;
    trace("QTY: "+quantity1);

    total1 = (quantity1 * 45);
    trace("TOTAL 2: "+total1);
    };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center