Need help clearing dynamic text fields and resetting a global number
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Need help clearing dynamic text fields and resetting a global number

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    7

    Need help clearing dynamic text fields and resetting a global number

    Hello, I have a till system that calculates the change for a small business that I am working on for my A-Level.
    Once an order has been completed I have a button that takes you back to the start of the order process and attemps to clear the dynamic text fields that contain the cost of the order, and the numbers inputted into the calculator. I have used the code txt.text = ""; to try and reset them, but it only makes the text invisible and remains until another cost is entered, while the number inputted to the calculator remains regardless.
    Can anybody find out why and how to fix it thanks?

  2. #2
    Senior Wabbit
    Join Date
    Jul 2008
    Location
    Winchester, Uk
    Posts
    215
    The most likely reason is a path issue.

    Make sure the actions are on Frame 1 and cover all frames on the root timeline.
    This will make sure the same var is used across all the frames.
    Also when assigning a type to a var don't use . even though the syntax will pick up the word text it will still think its a paths
    so txt.text = ""; is not the same as txt = "";

    Without see any code it would be hard to say for sure though its the most likely cause to your issue.

    Trust my code, and not my english.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    Thanks for the reply.
    Removing the .text on the end of the actionscript for the reset button does appear to remove the information from the dynamic boxes, however I am now unable to add anything to these dynamic text boxes in the next order.
    The code for the button is as follows.
    on (release) {
    gotoAndPlay(1);
    txt = "";
    change1 = "";
    cashpaid = "";
    }

    the txt is for the order display, the change1 is the calculated change dynamic text and the cashpaid is the amount the customer has given, inputted via a number pad.

    Could be problem be arising with the global which allows me to add the cost of items to the txt.text - _global.cost= 0.00; ?
    Thankyou

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,097
    Hi,

    If you can attach you fla file, then it would be easier to help you, if you are unable to attach it here, try somewhere like

    http://www.filedropper.com/

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    7
    Unfortunately the .fla is far too big for the 300kb limit, and the hostign websites are unfortunately blocked by the school system. I will attempt to upload it later on today

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,097
    Hi,

    Basically you haveyour text area called txt, which also has a var name of cost 1, so they got mixed up a bit.

    so remove the var from txt textfield and

    use this on your new order button instead of the code you have now
    PHP Code:
    on (release) {
        
    gotoAndPlay(1); 
        
    txt.text "";
        
    cost 0;
        
    secondnumber "";
        
    total "";

    and on your calculat button use this instead of what you have now
    PHP Code:
    on (release) {
    total Number(secondnumber) - Number(cost);

    i think that should get you going again, if not, say so

    also embed your fonts
    Last edited by fruitbeard; 02-05-2013 at 11:18 AM.

  7. #7
    Junior Member
    Join Date
    Dec 2012
    Posts
    7

    Solved

    That was brilliant Fruitbeard.
    That completely cleared all of the fields and allowed data to be re-entered.

    And to think i had been trying to do this all week.
    Thank a bunch

  8. #8
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,097
    Hi,

    Glad I could help big man

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

Poll by Flashkit.com