A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: If then Else statement load movieclip

  1. #1
    Member
    Join Date
    Apr 2007
    Posts
    56

    If then Else statement load movieclip

    I have built a calculator with a running total variable (stotal) this is working great. There are 30 buttons each having its own value each add or subtract from "stotal".

    The attached is a much scaled down and simplified version of the calculator. In this sample each button has a value of 200. If the user gets to 1000 or more I want to load an exiernal SWF "succes.swf" that notifies them they have reached 1000.

    Here is the AS for one of the buttons. I know I need to wtite this as an "If then Else If" statement in order to get it to work but I am not having much luck;
    q1a.onRelease = function(){
    if (a1a==true){
    a1a=false;
    _root.stotal -=200;
    }else{
    a1a=true;
    _root.stotal +=200;
    }
    }
    Attached Files Attached Files
    Last edited by AVaughn; 01-29-2011 at 05:05 PM.

  2. #2
    Member
    Join Date
    Apr 2007
    Posts
    56
    Think I may have it!!

    Actionscript Code:
    q1a.onRelease = function(){
        if(stotal>983)
            loadMovie("success.swf",0);
        else if(a1a==true){
            a1a=false;
            _root.stotal -=200;
        }else{
            a1a=true;
            _root.stotal +=200;
    }

  3. #3
    Member
    Join Date
    Apr 2007
    Posts
    56
    No Good! This sends success request after the fact ..... back to the drawing board, Need to check if "stotal" > 983 after the button is released and the "stotal" incremented. Double "If Then Else" for each button? is that possible, been lookig at this too long?
    Last edited by AVaughn; 01-29-2011 at 05:40 PM.

  4. #4
    Member
    Join Date
    Apr 2007
    Posts
    56
    Getting closer ......

    Actionscript Code:
    q1a.onRelease = function(){
        if (a1a==true){
            a1a=false;
            _root.stotal -=200;
            trace(stotal);
        }else{
            a1a=true;
            _root.stotal +=200;
            trace(stotal);
                if (stotal > 983)
                    loadMovie("success.swf",0);
                else
                    loadMovie(pass.swf,sholder_mc);
        }
    }

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    whats wrong with the last one? except your syntax is a bit off (need quotes around the last .swf you are trying to call)


    I also suggest NOT using loadMovie();

    and use a movieClipLoader() instance instead. (it gives you more control to execute actions than the older loadMovie() approach)

  6. #6
    Member
    Join Date
    Apr 2007
    Posts
    56
    Thanks for the response Whispers. Yes I omitted the ""'s. I have abandoned the load movie and using a final keyframe on the timeline to accomplish the same thing much cleaner. Thanks for your input. I am building a "US Budget Deficit Calculator", pretty complex. I have never used nested if's before but it seems to be working fine.

  7. #7

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