Glossy buttons in pure as3 code


I’ve been playing with the drawing classes, experimenting gradients and blending modes, and so I put together a small (basic) as3 class that generates a glossy button with pure code – no library assets.

You can download the class here.

The class constructor expects only 3 parameters:
@param rad = Width of button
@param darkColor = The color in top area, more dominant
@param lightColor = The color in the bottom area

* you can then place it anywhere, and use method setCaption(cap:String) to place a label on the button, though this is a very basic implementation of text handling, I focused on drawing..

Let me know if you liked it : )

    • celeiner
    • January 30th, 2009

    Excellent -got a rectangle??

    • Victor Y. Sklyar
    • June 2nd, 2010

    Hello!

    Can you show me how to handle press event on this button?

    rg = new RoundGlossy(30, 20, 30);
    rg.x = 100;
    rg.y = 100;
    //how to handle onButPress?

    sorry I am newbe in actionscript (

    • adi
    • June 2nd, 2010

    Hey Victor, using the class should be something like this:

    var blue:RoundGlossy = new RoundGlossy(30, 0×006699, 0x00FFFF);
    blue.x = 100;
    blue.y = 100;
    blue.setCaption(“GO”);
    this.addChild(blue);

    In order to add behavior you can simply add your function in the class instead of: ‘// do something’..

    Good luck!

    • Victor Y. Sklyar
    • June 2nd, 2010

    yes, i do so

    rg = new RoundGlossy(30, 20, 30);
    rg.x = 100;
    rg.y = 100;

    rg.setCaption(“test”);
    //rg.addEventListener(onButPress, onButPress); //what we need to do here to handle onButPress?
    addChild(rg);

    public function onPutPress():void
    {
    trace(“onButPress”);
    }

    • Victor Y. Sklyar
    • June 2nd, 2010

    eurika!

    just

    rg.addEventListener(MouseEvent.CLICK, onButPress);

  1. No trackbacks yet.