Hi there I am going to use AS3 to draw the box as below... you can download
the shapes.swf file here....

http://www.2shared.com/file/2247730/b78a543a/shape.html?


I have already figured out the border and gradient shape, but when I try to
combine them together, the gradient is gone.... any idea or good ways to
handle this?

THANK YOU VERY MUCH


======== HOW to test the code ======

1. Paste the class example code into a new AS file and give the file the
same name as the primary class (for example: GraphicsExample.as).
2. Create and save a new empty FLA file in the same directory as the AS
file.
3. In the Properties tab of the Property inspector enter the class name of
the primary class for the example in the Document class text box (for
example: GraphicsExample).
4. Save your changes to the FLA file.
5. Test the movie using the Control > Test Movie menu option.
===============================


======== AS3 Code ==========
package {
    import flash.display.DisplayObject ;
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.display.GradientType
    import flash.display.SpreadMethod
    import flash.geom.*

    public class GraphicsExample extends Sprite {
        private var shapeWidth:uint   = 500;
        private var shapeHeight:uint  = 20;
        //private var bgColor:uint    = 0xFFCC00;
        private var borderColor:uint  = 0x666666;
        private var borderSize:uint   = 0;
        private var cornerRadius:uint = 6;
        private var gutter:uint       = 5;
        private var xPostion:int      = 20;
        private var yPostion:int      = 20;

        public function GraphicsExample() {

            doDrawBackground();
            doDrawRoundRect();
            //refreshLayout();
        }

        private function doDrawRoundRect():void {
            var child:Shape = new Shape();
            //child.graphics.beginFill(bgColor);
            child.graphics.lineStyle(borderSize, borderColor);
            child.graphics.drawRoundRect(xPostion, yPostion, shapeWidth,
shapeHeight, cornerRadius);
            child.graphics.endFill();
            addChild(child);
            //child.x=300;
            //trace(child.x)
        }

        private function doDrawBackground():void {
            var child:Shape = new Shape();

              var fillType:String = GradientType.LINEAR;
              var colors:Array = [0x000000, 0x666666];
             var alphas:Array = [100, 100];
              var ratios:Array = [0, 255];
            var matr:Matrix = new Matrix();

            matr.createGradientBox(shapeWidth,shapeHeight, Math.PI / 2, 0,
0);
            var spreadMethod:String = SpreadMethod.PAD;

            child.graphics.beginGradientFill (fillType, colors, alphas,
ratios, matr, spreadMethod);
            //child.graphics.drawRect(xPostion,0,shapeWidth,shapeHeight);
            child.graphics.drawRoundRect(xPostion, 0, shapeWidth,
shapeHeight, cornerRadius);
            addChild(child);
        }

    }
}
============ END OF CODE ===========
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to