A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] messing with varriables (check my math?)

  1. #1
    Senior Member
    Join Date
    Mar 2005
    Location
    U.S.A . VA.
    Posts
    108

    resolved [RESOLVED] messing with varriables (check my math?)

    Back Story (not important to read)
    So im just experimenting with some variables after reading some tutorials (which were not clear and seemed to be typed up in a hurry) i decided just to mess around with it and make a button in the middle of a black screen which upon clicking will remove a random 1293 number from the dynamic number (boring i know but im just learning)

    So heres what i got, In my 1st frame i have
    Actionscript Code:
    stop();
    money = 9999999
    and in that frame i also have my button which after being clicked subtracts a random number from the "money" after clicked the button animates a lame tween and leaves - here is what my button has
    actionscript Code:
    on (release) { money -= random(9999); }
    on (release) {
    gotoAndPlay (2);
    }
    along down the timeline after the button has completed its lame tween i have actions in a frame here as follows
    actionscript Code:
    gotoAndStop(2);

    NOW HERES THE PROBLEM
    just before that frame that sends you back to frame 2 i have this in my frame
    Actionscript Code:
    if (_root.money==0)
    { gotoAndStop(26);

    -I was hoping that it would detect that the money has reached 0 and send me to frame 26 but instead all it does is just zoom past it letting my numbers drop into the negatives... any ideas or tutorials i should look at?
    Last edited by Ecuder; 05-27-2010 at 05:14 PM. Reason: [highlight=actionscrip] did not work 1st time
    How can you say so much, but say so little?

  2. #2
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Try:

    PHP Code:
    if (_root.money <=0){
         
    gotoAndStop(26);

    What you're saying is if and only if the money variable is equal to 0. What happens if it randomly drops below that, which in your issue, it does. So that should fix it.

  3. #3
    Senior Member
    Join Date
    Mar 2005
    Location
    U.S.A . VA.
    Posts
    108
    Quote Originally Posted by Osteel View Post
    What you're saying is if and only if the money variable is equal to 0. What happens if it randomly drops below that, which in your issue, it does. So that should fix it.
    Thanks Osteel!
    How can you say so much, but say so little?

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