A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Multiple button clicks before action takes place

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    5

    Multiple button clicks before action takes place

    I'm creating a simple color wheel mixer... there are three buttons: red, yellow and blue. I want to be able to select red and then yellow buttons... then go to the orange frame... or select yellow and then red buttons and go to the orange frame, etc... I'm sure there's an "if" "else" way of doing this in as3... any thoughts? I don't want to use check boxes... just buttons.

    Plans are in the works for a 6+ color wheel... hmmm.

    Thanx

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You can use a number scheme. Create a variable colNum
    var colNum:Number=0;
    Then when the red is pressed you add 1
    colNum=colNum+1;
    if(colNum==3)
    {
    gotoAndStop("orange");
    }
    When the yellow is pressed add 2
    colNum=colNum+2;
    if(colNum==3)
    {
    gotoAndStop("orange");
    }

    Something like this.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Nov 2008
    Posts
    5

    Thanx

    Many Thanks, I'll give it a shot

  4. #4
    Junior Member
    Join Date
    Nov 2008
    Posts
    5
    Thanks for your help!!!

    This is what I ended up using... thanks to you.

    Later, Graphician

    this.stop();

    var colNum:Number=0;

    red.addEventListener(MouseEvent.CLICK,clickHandler Red);
    yellow.addEventListener(MouseEvent.CLICK, clickHandlerYellow);
    blue.addEventListener(MouseEvent.CLICK, clickHandlerBlue);

    function clickHandlerRed(event:MouseEvent):void {
    colNum=colNum+1;
    if(colNum==11)
    gotoAndStop("orange");
    else if (colNum==31)
    gotoAndStop("violet");
    else if (colNum==1)
    gotoAndStop(1);
    else
    gotoAndStop("goback");
    }

    function clickHandlerYellow(event:MouseEvent):void {
    colNum=colNum+10;
    if(colNum==11)
    gotoAndStop("orange");
    else if (colNum==40)
    gotoAndStop("green");
    else if (colNum==10)
    gotoAndStop(1);
    else
    gotoAndStop("goback");
    }

    function clickHandlerBlue(event:MouseEvent):void {
    colNum=colNum+30;
    if(colNum==31)
    gotoAndStop("violet");
    else if (colNum==40)
    gotoAndStop("green");
    else if (colNum==30)
    gotoAndStop(1);
    else
    gotoAndStop("goback");
    }

  5. #5
    Junior Member
    Join Date
    Nov 2008
    Posts
    3

    Thumbs up

    I LOVE this code, thank you!!

    Is there a way to make like a "reset" button. It seems to get confused if you click on it a bunch different combinations.


    Or do I have something off in my code? There are two different color combos, spa color and the color of the wood on the sides of the spa. After you click a few different combos it stops working:
    this.stop();

    var colNum:Number=0;

    grayWood.addEventListener(MouseEvent.CLICK,clickHa ndlerGraywood);
    redWood.addEventListener(MouseEvent.CLICK, clickHandlerRedwood);
    navyShell.addEventListener(MouseEvent.CLICK, clickHandlerNavyshell);
    whiteShell.addEventListener(MouseEvent.CLICK, clickHandlerWhiteshell);

    function clickHandlerGraywood(event:MouseEvent):void {
    colNum=colNum+11;
    if(colNum==41)
    gotoAndStop("blueGray");
    else if (colNum==51)
    gotoAndStop("whiteGray");
    else if (colNum==11)
    gotoAndStop(1);
    else
    gotoAndStop("goback");
    }

    function clickHandlerRedwood(event:MouseEvent):void {
    colNum=colNum+20;
    if(colNum==50)
    gotoAndStop("blueRed");
    else if (colNum==60)
    gotoAndStop("whiteRed");
    else if (colNum==20)
    gotoAndStop(1);
    else
    gotoAndStop("goback");
    }

    function clickHandlerNavyshell(event:MouseEvent):void {
    colNum=colNum+30;
    if(colNum==41)
    gotoAndStop("blueGray");
    else if (colNum==50)
    gotoAndStop("blueRed");
    else if (colNum==30)
    gotoAndStop(1);
    else
    gotoAndStop("goback");
    }

    function clickHandlerWhiteshell(event:MouseEvent):void {
    colNum=colNum+40;
    if(colNum==51)
    gotoAndStop("whiteGray");
    else if (colNum==60)
    gotoAndStop("whiteRed");
    else if (colNum==40)
    gotoAndStop(1);
    else
    gotoAndStop("goback");
    }
    Last edited by BrandyQ; 11-21-2008 at 07:54 PM.

  6. #6
    Junior Member
    Join Date
    Nov 2008
    Posts
    5
    BrandyQ...
    Thanx for the complements!

    On the go back frame, you must reset the variable to 0...

    this.stop();

    goback.addEventListener(MouseEvent.CLICK, clickHandlerGoback);

    function clickHandlerGoback(event:MouseEvent):void {
    var colNum:Number=0;
    gotoAndStop("start");
    }


    Also, on each of the mixed color frames, I put...

    this.stop();

    gobackorange.addEventListener(MouseEvent.CLICK, clickHandlerGobackorange);

    function clickHandlerGobackorange(event:MouseEvent):void {
    var colNum:Number=0;
    gotoAndStop("start");
    }


    You may have noticed that I've given frame 1 the frame label "start" (I put in a new frame one before it). (I should have labelled all the frames when I first started since I'm always moving frames around!)... Anyway, I tried to attach my latest fla file... which is still in progress... but it's too large... even if I zip it.
    This is my first frame...

    this.stop();

    onward.addEventListener(MouseEvent.CLICK,clickHand lerOnward);

    function clickHandlerOnward(event:MouseEvent):void {

    gotoAndStop("start");
    }

    Good Luck with your code...
    Later,
    Graphician

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