A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] Custom Buttons/check boxes Help

  1. #1
    Member
    Join Date
    Apr 2007
    Posts
    56

    resolved [RESOLVED] Custom Buttons/check boxes Help

    I have to build a Flash app that has three buttons. They are blue by default however when moused over they turn Red. When you mouse off they go back to blue. However IF CLICKED they turn and stay red.

    I have created the buttons as movie clips and have no problem with the mouse over feature. It is getting it to stay RED when clicked and not allowed to go back to default color or BLUE when mouse is moved off button after it is clicked. Anyone have a sample of this?

    Also I need for each button to be assigned a numeric value so when it is clicked the button value is added to a running total that can be displayed after all selections are made and a CALCULATE button is clicked.

    Thanks, this board has saved me more than I can count.

    Adam

  2. #2
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    put this code on the first frame of the movieclip
    Code:
    clicked=false;
    this.onEnterFrame=function(){
        if(clicked || hitTest(_xmouse,_ymouse,false))
            this.gotoAndStop("red")
        else
            this.gotoAndStop("blue");
    }
    onPress=function(){
        clicked=!clicked;
    }
    Z¡µµ¥ D££

    Soup In A Box

  3. #3
    Member
    Join Date
    Apr 2007
    Posts
    56
    Not sure what the code characters are between "Clicked" and "Hittest" look like two vertical lines?

    Now I would like to add a mouse over and off feature, so the button MC turns red on mouse over and back to blue on mouse off. I also want to display some addition text on the mouse over and not on the click so I have created a separate labeled frame called "over" assuming we can use existing frame label "blue" for mouse off. I am sure you can tell what happens the red is only seen for a split second on the mouse over.

    Here is what I have:


    clicked=false;

    this.onRollOver=function(){
    gotoAndPlay("over");
    }

    this.onRollOut = function() {
    gotoAndPlay("blue");
    }


    this.onEnterFrame=function(){
    if(clicked || hitTest(_xmouse,_ymouse,false))
    this.gotoAndStop("red")
    else
    this.gotoAndStop("blue");
    }
    onPress=function(){
    clicked=!clicked;
    }
    Last edited by AVaughn; 07-23-2010 at 12:18 PM.

  4. #4
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    First of all, the "||" means "or"


    Try this code then:
    Code:
    clicked=false;
    over=false;
    this.onRollOver=function(){
        over=true;
    }
    this.onRollOut=function(){
        over=false;
    }
    this.onEnterFrame=function(){
        if(clicked)
            this.gotoAndStop("red");
        else if(over)
            this.gotoAndStop("over")
        else
            this.gotoAndStop("blue");
    }
    onPress=function(){
        clicked=!clicked;
    }
    Z¡µµ¥ D££

    Soup In A Box

  5. #5
    Member
    Join Date
    Apr 2007
    Posts
    56
    Zippy Thanks buddy, worked like a charm. I am a fairly good designer and illustrator if I can ever pay back the favor with art work let me know.

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