08Aug

APE Project - Step 4 - Adding a Car

No comments

So I pulled a Car class from an older project of mine and decided to integrate it into my project here…. gotta love the ease of integration of classes with Actionscript 3! I also added in some walls to the left and right side to prevent the car and balls to move outside of the [...]

13Jun

Creating Multiple Objects with Actionscript

3 comments so far

So I have recently had a number of requests on how to create multiple objects of a class as well as how to manipulate them. I decided to write this short demo which will just create an object, which is in a file called c.as which happens to be just a circle. If you click [...]

07May

Round Rectangle with Actionscript

No comments

A class to generate a rounded cornered rectangle which I am using in one of my current projects:

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

public class RoundRectangle extends Sprite {
[...]

03Mar

[AS 3] Drawing Dynamic Line Curves with curveTo Method

No comments

Demonstration of the curveTo method. Simply roll your mouse over the movie below.

package
{
import flash.display.Sprite;
import flash.events.MouseEvent;

public class CurveToExample extends Sprite
{
public function CurveToExample()
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, drawCurve);
}

private function drawCurve(m:MouseEvent):void
{
// clear the board on each Mouse Move
graphics.clear();

// draw the line
graphics.lineStyle(1);
graphics.moveTo(0,stage.stageHeight / 2);
graphics.curveTo(mouseX,mouseY,stage.stageWidth,stage.stageHeight / 2);
}
}
}

a2a_linkname=”[AS 3] Drawing Dynamic Line Curves [...]

13Feb

[AS 3] Recreating the Drawing Tool with Actionscript 3

No comments

Simply press and drag your mouse around the flash movie below.

package
{
import flash.display.Sprite;
import flash.display.Graphics;
import flash.events.MouseEvent;
import flash.events.Event;

public class DrawingTool extends Sprite
{
private var drawing:Boolean;

public function DrawingTool()
{
graphics.lineStyle(1,0xffffff);
graphics.moveTo(mouseX,mouseY);

stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);

addEventListener(Event.ENTER_FRAME, Drawing);
}

private function MouseDown(m:MouseEvent):void
{
graphics.lineStyle(1,Math.random() * 0xffffff);
drawing = true;
}

private function MouseUp(m:MouseEvent):void
{
drawing = false;
}

private function Drawing(e:Event):void
{
if (drawing)
{
this.graphics.lineTo(mouseX, mouseY);
}
else
{
this.graphics.moveTo(mouseX, mouseY);
}
}
}
}

a2a_linkname=”[AS 3] Recreating [...]