Sunday, 11 September 2011

Setting up Minimalcomps in AS3

In this quick post I will show you how to set up Minimalcomps in Actionscript 3. Firstly, open up a new AS3 FLA file and save it with whatever name you wish. Then download the Minimalcomps zip file from here. The zip file contains an ‘assets’ folder and a ‘com’ folder. Copy both of these folders into the same directory as your FLA file.

In your FLA file open up the Actions panel and add the following code. I have added the PushButton and the Text components as an example. The Minimalcomps documentation can be found here.

import com.bit101.components.PushButton;
import com.bit101.components.Text;

var pButton:PushButton = new PushButton(this, 10, 20, "A button", clicked);

function clicked(e:Event):void
 trace("button clicked");

var tArea:Text = new Text(this, 10, 70, 'Some text');

In this example I have replaced the colour picker, slider and push button components from Line drawing tutorial for the Minimalcomps components.

import com.bit101.components.ColorChooser;
import com.bit101.components.Slider;
import com.bit101.components.PushButton;

var pushButton:PushButton = new PushButton(this, 280, 265, 'Clear', clearScreen);
var colorChooser:ColorChooser = new ColorChooser(this, 17, 268,0x000000); 
var slider:Slider = new Slider("horizontal", this, 140, 271);

var drawingLine:Sprite = new Sprite();

canvas.addEventListener(MouseEvent.MOUSE_DOWN, mDown);
stage.addEventListener(MouseEvent.MOUSE_UP, mUp);

function mDown(e:MouseEvent):void {, colorChooser.value);, mouseY);
 canvas.addEventListener(MouseEvent.MOUSE_MOVE, mMove);

function mMove(e:MouseEvent):void {, mouseY);

function mUp(e:MouseEvent):void {
 canvas.removeEventListener(MouseEvent.MOUSE_MOVE, mMove);

function clearScreen(e:Event):void {;


  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP