Sunday, 18 April 2010

Unsmiley face class in Actionscript 3

I previously wrote a post called Unsmiley face in Actionscript 3 where I created an unhappy face using the drawCircle() and curveTo() methods from the AS3 graphics class. I have now created a class called unhappyFace shown below.

Update 10/06/10: If you don’t want an unsmiley face then I now have an option for a smiley face.

* Unhappy face class
* Created by ILIKE2FLASH.COM
* Version 1
package com.ilike2flash{

import flash.display.Shape;
import flash.display.MovieClip;

public class unhappyFace extends MovieClip {

private var my_shape:Shape=new Shape();
private var xposition:uint;
private var yposition:uint;
private var colour:uint;
private var lineThickness:uint;
private var happyFace:Boolean;

* @param lThick The line thickness of the face.
* @param col The face colour.
* @param xpos The x position of the face.
* @param ypos The y position of the face.
* @param hf hf set true for smiley face.
public function unhappyFace(lThick:uint, col:uint, xpos:int, ypos:int,hF:Boolean = false) {

private function drawFace():void {
my_shape.y=yposition;;;, 0, 195, 190);;,47,24,37);,47,24,37);;

if (happyFace) {,130);,200,160,130);
} else {,150);,120,161,150);


To use this class you need save the class file above in a folder call ‘ilike2flash’ within a folder class ‘com’. You then need to place the com folder in the same directory as your fla file or setup a class path. Then simply add the following code inside your fla file.
//Import the unhappyface class.
import com.ilike2flash.unhappyFace

//Create a new instance of the unhappy face class and add it onto the stage.
//If you want a smiley face then change the last parameter to true instead of false.
var myFace: unhappyFace = new unhappyFace(3, 0xFF3603, 0, 0,false);


  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP