12Feb

[AS 3] Creating a Radial Gradient with the Matrix Class

No comments

Here is an example of the ability to create a gradient fill within a bounding area utilizing the Matrix class. I used the Matrix class because this is the class that will allow one to capture properties of the gradient. The Matrix class is a grid that includes the combination of scale (’a’ and ‘d’), [...]

29Jan

[AS 3] Drawing Lines across the Stage

No comments

Today I just wanted to display a defined numer of lines with various angles to span across the stage.. nothing too exciting here, but this will be the groundwork for some future projects that I have going on:


Here is the basic Line.as file:

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

public class Line [...]

18Jan

[AS 3] Drawing Lines to Mouse Point

No comments

I just decided to build this simple interactive movie that will simply draw lines from the center of the stage to your mouse position and then closes out the drawing to form a triangle. This is just using the simple methods of:

graphics.clear
graphics.moveTo
graphics.lineStyle
graphics.beginFill and graphics.endFill
graphics.lineTo

Full documentation here.
If you hover your mouse over the movie below it [...]

16Jan

[AS 3] Drawing a Rectangle

No comments

A simple class using the drawRect method to draw a rectangle. By default this will render a blue 10×10 (yeah, I know it is a square) and place it at position 0,0 of the stage.

package
{
import flash.display.Sprite;

public class DrawRectangle extends Sprite
{
private var xPos:Number;
private var yPos:Number;
private var rWidth:Number;
private var rHeight:Number;
private var color:uint;

public function DrawRectangle(xPos:Number=0,yPos:Number=0,rWidth:Number=10,rHeight:Number=10,color:uint=0×336699)
{
this.graphics.beginFill(color);
this.graphics.drawRect(xPos,yPos,rWidth,rHeight);
this.graphics.endFill();
}
}
}

[...]

09Jan

[AS 3] Drawing a Circle with Actionscript

No comments

The following code with draw a circle, apply a color fill, and position it in the center of your stage:

package {
import flash.display.Sprite;

public class DrawCircle extends Sprite {
private var radius:Number;
private var color:uint;

public function DrawCircle(radius:Number=20, color:uint=0×336699) {
// center the circle - you can put the x and y positions as
// parameters of this function.. i just opted [...]