Pencil tool drawing using flash actionscript

Pencil tool drawing flash actionscript.

var _pencilHold:Boolean = false;

function PencilDrawing():void
{
	graphics.lineStyle(1,0x000000);

	stage.addEventListener(MouseEvent.MOUSE_DOWN, StartDrawing, false, 0, true);
	stage.addEventListener(MouseEvent.MOUSE_MOVE, Drawing, false, 0, true);
	stage.addEventListener(MouseEvent.MOUSE_UP,   StopDrawing, false, 0, true);
}

function StartDrawing($e:MouseEvent):void
{
	graphics.moveTo( mouseX, mouseY);
	_pencilHold = true;
}

function Drawing($e:MouseEvent):void
{
	if(_pencilHold)
	graphics.lineTo(mouseX,mouseY);

}

function StopDrawing($e:MouseEvent):void
{
	_pencilHold = false;
}

PencilDrawing();

This movie requires Flash Player 9

draw circle with gradient style using action script


var circle:Shape = new Shape();
addChild(circle);
circle.x = circle.y = 150;
circle.graphics.lineStyle(40);

var gradientColors:Array =
	[
		 0xFF0000,
		 0xFFFF00,
		 0xFF00FF,
		 0xFF6600,
		 0x00FFFF,
		 0x2E0854,
		 0x8F5E00,
		 0x8F5E99,
		 0xFFFF00,
		 0xFF00FF,
		 0xFF6600
	];
var gradientAlphas:Array = [1,1,1,1,1,1,1,1,1,1,1];
var gradientRatios:Array = [0,25,50,75,100,125,150,175,200,225,250];

circle.graphics.lineGradientStyle(GradientType.LINEAR, gradientColors, gradientAlphas, gradientRatios);

circle.graphics.drawCircle(-10, -10, 100);         

This movie requires Flash Player 9

draw Ellipse with flash action script

package druva {

 import flash.display.*;

 public class drawEllipse extends Sprite {

 public function drawEllipse() {
 var canvas:Shape = new Shape(  );
 canvas.graphics.lineStyle(3, 0xFF0000);
 canvas.graphics.drawEllipse(0,0,100,50);
 addChild(canvas);

 }
 }
}

(more…)

CapsStyle, JointStyle, LineScaleMode in flash action script

The below code is how to use LineScaleMode, CapsStyle, JointStyle in lineStyle of flash action script:

var child:Shape = new Shape();

child.graphics.lineStyle(30, 0x000000, 1, false, LineScaleMode.HORIZONTAL, CapsStyle.ROUND, JointStyle.BEVEL, 1);
child.graphics.moveTo(50, 50);
child.graphics.lineTo(100, 50);
child.graphics.endFill();

addChild(child);

How to draw grid using flash actionscript

The below code is used to draw grid using flash actionscript:


function drawGrid(lineSize, lineColor):void
{
	var grid:Sprite = new Sprite;

	grid.graphics.lineStyle(1, lineColor);

	for(var i:Number = 0; i < stage.stageWidth / lineSize; i++)
	{
		grid.graphics.moveTo(0, lineSize * i);
		grid.graphics.lineTo(stage.stageWidth, lineSize * i);

		grid.graphics.moveTo(lineSize * i, 0);
		grid.graphics.lineTo(lineSize * i, stage.stageHeight);
	}
	grid.graphics.endFill();
	addChild(grid);
}

drawGrid(5, 0x000000);

How to Draw a Square with Flash Actionscript 3.0 – AS3

simple Example to draw square using flash actionscript

this example show how to use lineStyle, drawRect, Shape

package druva {

import flash.display.*;

public class drawSquare extends Sprite {

public function drawSquare() {
var canvas:Shape = new Shape( );
canvas.graphics.lineStyle(3, 0xFF0000);
canvas.graphics.drawRect(10,10,100,100);
addChild(canvas);

}
}
}

How to Draw a Circle with Flash Actionscript 3.0 – AS3

package druva {

 import flash.display.*;

 public class drawCircle extends Sprite {

 public function drawCircle() {
 var canvas:Shape = new Shape(  );
 canvas.graphics.lineStyle(3, 0xFF0000);
 canvas.graphics.drawCircle(100,100,50);
 addChild(canvas);

 }
 }
}