Graphics (AS3)

Le script

var Courbe :Shape=new Shape();
Courbe.graphics.lineStyle(1,0,1);
Courbe.graphics.moveTo(10,20);
Courbe.graphics.curveTo(90,15,40,40);
addChild(Courbe);

[hidepost]

var Rect :Shape=new Shape();
Rect.graphics.lineStyle(1,0xcc0000,1);
Rect.graphics.drawRect(0,0,80,30);
addChild(Rect);
Rect.x=55;
Rect.y=10;
Rect.rotation=10;

var Rond :Shape=new Shape();
Rond.graphics.lineStyle(.5,0x282F59,1);
Rond.graphics.beginFill(0×497589,.5);
Rond.graphics.drawCircle(133,25,10);
addChild(Rond);

var RectRound :Shape=new Shape();
RectRound.graphics.lineStyle(2,0x282F59,1);
RectRound.graphics.beginFill(0×497589,.2);
RectRound.graphics.drawRoundRect(160,10,60,40,20);
addChild(RectRound);

 

Le script dans un fichier classe :

package {
    import flash.display.Sprite;
    import flash.display.Graphics;

    public class Tracer extends Sprite {
        public var RectRound:Sprite;

        function Tracer() {
            RectRound=new Sprite();

            RectRound.graphics.lineStyle(2,0x282F59,1);
            RectRound.graphics.beginFill(0×497589,.2);
            RectRound.graphics.drawRoundRect(160,10,60,40,20);
            addChild(RectRound);
        }
    }
}